def login(client, oidc_auth_url, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://localhost:9004' # azure only supports 'localhost' url = ( '{oidc_auth_url}?' 'response_type=code' '&client_id={client_id}' '&redirect_uri={redirect_uri}' '&scope=openid%20profile%20email' '&state={state}' ).format( oidc_auth_url=oidc_auth_url, client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token ) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { 'code': access_token, 'clientId': client_id, 'redirectUri': redirect_uri } return client.token('openid', data)
def login(client, username, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://127.0.0.1:9004' url = ( 'https://accounts.google.com/o/oauth2/v2/auth?' 'scope=email%20profile&' 'response_type=code&' 'client_id={client_id}&' 'redirect_uri={redirect_uri}&' 'state={state}&' 'login_hint={username}' ).format( client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token, username=username ) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { 'code': access_token, 'clientId': client_id, 'redirectUri': redirect_uri } return client.token('google', data)
def login(client, gitlab_url, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://127.0.0.1:9004' url = ( '{gitlab_url}/oauth/authorize?' 'response_type=code&' 'client_id={client_id}&' 'redirect_uri={redirect_uri}&' 'scope=openid&' 'state={state}' ).format( gitlab_url=gitlab_url, client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token ) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { 'code': access_token, 'clientId': client_id, 'redirectUri': redirect_uri } return client.token('gitlab', data)
def login(client, azure_tenant, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://localhost:9004' url = ( 'https://login.microsoftonline.com/{azure_tenant}/oauth2/v2.0/authorize?' 'response_type=code' '&client_id={client_id}' '&redirect_uri={redirect_uri}' '&scope=openid%20profile%20email' '&state={state}').format(azure_tenant=azure_tenant, client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { 'code': access_token, 'clientId': client_id, 'redirectUri': redirect_uri } return client.token('azure', data)
def login(client, github_url, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://127.0.0.1:9004' url = ( '{github_url}/login/oauth/authorize?' 'client_id={client_id}&' 'redirect_uri={redirect_uri}&' 'scope=user:email%20read:org&' 'state={state}&' 'allow_signup=false' ).format( github_url=github_url, client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token ) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { 'code': access_token, 'clientId': client_id, 'redirectUri': redirect_uri } return client.token('github', data)
def login(client, username, client_id): xsrf_token = str(uuid4()) redirect_uri = 'http://127.0.0.1:9004' url = ('https://accounts.google.com/o/oauth2/v2/auth?' 'scope=email%20profile&' 'response_type=code&' 'client_id={client_id}&' 'redirect_uri={redirect_uri}&' 'state={state}&' 'login_hint={username}').format(client_id=client_id, redirect_uri=redirect_uri, state=xsrf_token, username=username) webbrowser.open(url, new=0, autoraise=True) auth = TokenHandler() access_token = auth.get_access_token(xsrf_token) data = { "code": access_token, "clientId": client_id, "redirectUri": redirect_uri } return client.token('google', data)