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

(Suggestion) Code snippet for auth #3

Open
hmkim opened this issue Mar 2, 2022 · 1 comment
Open

(Suggestion) Code snippet for auth #3

hmkim opened this issue Mar 2, 2022 · 1 comment

Comments

@hmkim
Copy link

hmkim commented Mar 2, 2022

No description provided.

@hmkim
Copy link
Author

hmkim commented Mar 2, 2022

Method 1. By Device

flow = app.initiate_device_flow(scopes=scopes)
print(flow["message"])
result = app.acquire_token_by_device_flow(flow)

Method 2. By Code (Maybe change this)

redirect_uri = 'https://login.microsoftonline.com/common/oauth2/nativeclient'

app = msal.ConfidentialClientApplication(conn['client_id'], client_credential=conn['secret'], token_cache=cache)
url = app.get_authorization_request_url(scopes, redirect_uri=redirect_uri)

print('Navigate to the following url in a web browser:')
print(url)

print('After login, you will be redirected to a blank (or error) page with a url containing an access code. Paste the url below.')
resp = input('Response url: ')

i = resp.find('code') + 5
code = resp[i : resp.find('&', i)] if i > 4 else resp

result = app.acquire_token_by_authorization_code(code, scopes, redirect_uri=redirect_uri)

@hmkim hmkim changed the title Suggestion( Code suggestion for auth Mar 2, 2022
@hmkim hmkim changed the title Code suggestion for auth (Suggestion) Code snippet for auth Mar 2, 2022
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

No branches or pull requests

1 participant