Closed agn-7 closed 1 year ago
I adopt an alternative approach to solve this issue, using furl
PyPI package:
from furl import furl
url, state_ = account.con.get_authorization_url(
requested_scopes=SCOPES,
redirect_uri="http://127.0.0.1:8090/microsoft/oauth2callback",
)
f = furl(url)
f.args["state"] = "1234567890"
f.args["prompt"] = "consent"
print(f.url)
Out:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=xxx&redirect_uri=http%3A%2F%2F127.0.0.1%3A8090%2Fmicrosoft%2Foauth2callback&scope=Calendars.ReadWrite+offline_access&state=1234567890&access_type=offline&prompt=consent
Now, state
is changed and prompt
is added properly.
With the #993 PR, you can simply add the optional parameters:
from O365 import Account
CLIENT_ID = "xxx"
SECRET_ID = 'yyy'
CLIENT_SECRET = "zzz"
SCOPES = ['Calendars.ReadWrite', 'offline_access']
credentials = (CLIENT_ID, CLIENT_SECRET)
account = Account(credentials)
url, state = account.con.get_authorization_url(
requested_scopes=SCOPES,
redirect_uri="http://127.0.0.1:8090/microsoft/oauth2callback",
state="1234567890",
prompt='consent',
)
print(url)
Out:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=xxx&redirect_uri=http%3A%2F%2F127.0.0.1%3A8090%2Fmicrosoft%2Foauth2callback&scope=Calendars.ReadWrite+offline_access&state=1234567890&access_type=offline&prompt=consent
state
is changed and prompt
is set to consent
properly.
merged
I am going to pass the parameters such as
state
andprompt
for getting the authorization URL. However, thestate
param is generated randomly despite the fact that I am going to set it arbitrarily. Moreover, I want to addprompt
param withconsent
argument which is not possible.Out:
As you can see, the
state
isn't changed, andprompt=consent
isn't added either.