Allow Auth Via google.oauth2.credentials Credentials(token=".")#205
Open
TimDiam0nd wants to merge 1 commit intogoogle:mainfrom
Open
Allow Auth Via google.oauth2.credentials Credentials(token=".")#205TimDiam0nd wants to merge 1 commit intogoogle:mainfrom
TimDiam0nd wants to merge 1 commit intogoogle:mainfrom
Conversation
Add check for 'with_scopes' method in credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the
Credentialsclass fromgoogle.oauth2.credentialsit is possible to provide atokenparam, which is an OAuth 2.0 bearer token.i.e.
Currently this fails (when passing to the secops lib) with the following error:
Traceback (most recent call last): File "/home/temp/secops-wrapper/src/secops/auth.py", line 191, in _get_credentials google_credentials = credentials.with_scopes(self.scopes) ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Credentials' object has no attribute 'with_scopes'. Did you mean: 'has_scopes'? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/temp/secops-wrapper/src/secops/client.py", line 46, in __init__ self.auth = SecOpsAuth( ~~~~~~~~~~^ credentials=credentials, ^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... retry_config=retry_config, ^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/home/temp/secops-wrapper/src/secops/auth.py", line 171, in __init__ self.credentials = self._get_credentials( ~~~~~~~~~~~~~~~~~~~~~^ credentials, ^^^^^^^^^^^^ ...<2 lines>... impersonate_service_account, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/home/temp/secops-wrapper/src/secops/auth.py", line 221, in _get_credentials raise AuthenticationError( f"Failed to get credentials: {str(e)}" ) from e secops.exceptions.AuthenticationError: Failed to get credentials: 'Credentials' object has no attribute 'with_scopes'This is because the scopes are already included as part of the Oauth token.
minimal reproducible: