Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

Problem

The create_user2_with_http_info and update_user2_with_http_info methods in users_v2_api.py had their _auth_settings variable incorrectly set to an empty list [], causing 401 Unauthorized errors when attempting to create or update users through the V2 API.

This inconsistency meant that users had to manually provide authentication headers as a workaround:

user_api.create_user2(user=user_data, _headers={"Authorization": f"bearer {config.access_token}"})

Solution

Updated both methods to correctly use _auth_settings = ['OAuth2'], consistent with:

  • All other methods in users_v2_api.py (get_user2, delete_user2, list_users2, get_user_apps2)
  • The corresponding methods in users_v1_api.py (create_user, update_user)

Changes

File: onelogin/api/users_v2_api.py

  • Line 183: create_user2_with_http_info - Fixed _auth_settings = []_auth_settings = ['OAuth2']
  • Line 1069: update_user2_with_http_info - Fixed _auth_settings = []_auth_settings = ['OAuth2']

Impact

  • ✅ Fixes 401 Unauthorized errors when creating users via V2 API
  • ✅ Fixes 401 Unauthorized errors when updating users via V2 API
  • ✅ Removes need for manual authentication header workarounds
  • ✅ OAuth2 authentication now works automatically through SDK configuration
  • ✅ Aligns V2 API behavior with V1 API and other V2 methods

Testing

All existing tests pass:

  • test_users_v2_api.py: 6/6 tests passing
  • test_users_v1_api.py: 15/15 tests passing

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>_auth_settings empty for create and update users</issue_title>
<issue_description>Hi,

The _auth_settings variable for 'update_user2_with_http_info' and 'create_user2_with_http_info' in users_v2_api.py is not set with 'OAuth2' causing a 401 unauthorized error.

I can currently work around this by manually providing the headers (_headers={"Authorization": f"bearer {onelogin_configuration.access_token}"}).</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #111

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Subterrane <5290140+Subterrane@users.noreply.github.com>
Copilot AI changed the title [WIP] _auth_settings empty for create and update users Fix missing OAuth2 authentication for create_user2 and update_user2 methods Oct 6, 2025
Copilot AI requested a review from Subterrane October 6, 2025 13:00
@Subterrane Subterrane marked this pull request as ready for review October 6, 2025 18:44
@Subterrane Subterrane merged commit 5cb6378 into main Oct 6, 2025
7 checks passed
@Subterrane Subterrane deleted the copilot/fix-e2762c28-922c-4700-8d4f-05df4a4e2c0c branch October 6, 2025 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_auth_settings empty for create and update users

2 participants