Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scopes process of get_authorization_url #577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

obsd
Copy link

@obsd obsd commented Feb 18, 2021

The function get_authorization_url is passing scopes to get_session without process, so you get an error that there aren't such scopes.
You can see here how the scopes look like before the fix and compare them to the scopes that did work:

print(requested_scopes, self.scopes)
['basic', 'message_all'] ['https://graph.microsoft.com/Mail.ReadWrite', 'https://graph.microsoft.com/Mail.Send', 'offline_access', 'https://graph.microsoft.com/User.Read']

and after the fix:

protocol = MSGraphProtocol()
protocol.get_scopes_for(requested_scopes)
['https://graph.microsoft.com/Mail.ReadWrite', 'https://graph.microsoft.com/Mail.Send', 'offline_access', 'https://graph.microsoft.com/User.Read']

@odedvisiblerisk
Copy link

@janscas can you review it?

Copy link
Member

@alejcas alejcas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
I know, but this is on purpose. The connection is "protocol" agnostic. It doesn't know the protocol used and you can't assume is MsGraphProtocol.

This is somehow a design decision made a long time ago.
For this reason, when not using the Account object, you should use a Connection and a Protocol.
Pass the scopes to the protocol get_scopes_for method and then pass the returned scopes to the Connection (or directly to the method get_authorization_urlif you prefer).

Thanks!

@@ -448,7 +448,12 @@ def get_authorization_url(self, requested_scopes=None,

redirect_uri = redirect_uri or self.oauth_redirect_url

scopes = requested_scopes or self.scopes
if requested_scopes:
protocol = MSGraphProtocol()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't assume here that the protocol in use is MSGraphProtocol.

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.

None yet

3 participants