How to login through a SAML-connection using the auth0-python library?

Hi, I’m using the auth0-python library (GitHub - auth0/auth0-python: Auth0 SDK for Python) and would like to enable user login through my SAML-connection.

I’m trying to use the GetToken class, but I’m really having trouble using the docs to acheive what I want.

Please help!

Hey there @diddeper!

Would you mind sharing a little bit more context around how you’re building it?

Can you share with us any code snippets and link to the docs you used cause you linked main docs site and I’m not sure which tutorial you use.

Thanks a lot!

Thanks for the swift reply, @konrad.sopala!

What I’m trying to achieve is to let users authenticate and login via Python (not a web app, so no flask), something similar to what the .webAuth method provides for a mobile app.

I’ve been trying to use the login method from GetToken (auth0-python/get_token.py at d18417c8e9284f84d5353157a1eaa360e6634a69 · auth0/auth0-python · GitHub).

I’ve also tried the client_credentials method from GetToken:

//Code starts
request = GetToken(domain)
response = request.client_credentials(clientId, clientSecret, ‘https://mydomain.com/api/v2/’.format(domain))
token = response[‘access_token’]

from auth0.v3.management import Auth0

auth0 = Auth0(domain, token)

print(auth0.users.get(‘user_id’))
//Code ends

I have not managed to achieve anything with the login method as my only connection is a SAML connection and users have to authenticate with username/password towards the Identity Provider.

The client_credentials method provides me with the attributes that I want, but this method needs to know the user_id. I can’t get hold of the user_id unless the user already is authenticated through the Identity Provider.

I’ve looked at these quickstart as well, but these are meant for web apps bulit on Flask: Auth0 Python API SDK Quickstarts: Authorization
Auth0 Python SDK Quickstarts: Login