# How to retrieve access\_token for user with only email, client id and client secret?

**URL:** <https://community.auth0.com/t/how-to-retrieve-access-token-for-user-with-only-email-client-id-and-client-secret/133611>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [May 7, 2024, 5:02pm UTC](https://community.auth0.com/t/how-to-retrieve-access-token-for-user-with-only-email-client-id-and-client-secret/133611 "2024-05-07T17:02:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devans](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@devans](https://community.auth0.com/u/devans)\
**Post date:** [May 7, 2024, 5:02pm UTC](https://community.auth0.com/t/how-to-retrieve-access-token-for-user-with-only-email-client-id-and-client-secret/133611/1 "2024-05-07T17:02:54Z")

</div>

Hello Auth0,

My company is currently working on integrating Auth0 but we have run into an issue with being able to retrieve a user’s access\_token from just their email.  
We currently have a paradigm that authenticates a user via a sign-in code on our end. Once this user is authenticate on our end, we need to pass their email to retrieve Auth0’s information for that user (access\_token, JWT token, etc).

We have tried simply omitting the password field but this gives us an error. Is there a different endpoint or method we can use to achieve the goal of getting an access\_token for a user without specifying their password?

Here is the current code we are using for authenticating with a password:

```auto
def authenticate_user(self, login, password):
        """
        Authenticates a user in Auth0 using their login credentials. This function constructs a payload with 
        the necessary details (including client credentials and user login information) and sends a request to 
        Auth0's OAuth token endpoint to authenticate the user.

        Args:
            login (str): The username or email of the user attempting to log in.
            password (str): The password of the user.

        Returns:
            dict: A dictionary containing the authentication token and other information if the login is successful, 
                or an empty dictionary if the login fails. The response includes information such as the access token, 
                id token, and scope.
        """
        url = f"https://{self.auth0_domain}/oauth/token"
        headers = {'content-type': "application/json"}
        payload = {
            "client_id": self.client_id,
            "client_secret": self.client_secret,
            "grant_type": "http://auth0.com/oauth/grant-type/password-realm",
            "username": str(login).lower(),
            "password": password,
            "audience": f"https://{self.auth0_domain}/api/v2/",
            "scope": "openid profile email",
            "realm": self.auth0_env
        }

        response = requests.post(url, json=payload, headers=headers)
        print(f"Response Text: {response.text}")

        if response.status_code != 200:
            print(f"Unsuccessful login for {login} {response.status_code}")
            return {}
        else:
            return response.json()

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 7, 2024, 11:51pm UTC](https://community.auth0.com/t/how-to-retrieve-access-token-for-user-with-only-email-client-id-and-client-secret/133611/3 "2024-05-07T23:51:25Z")

</div>

Hey there @devans welcome to the community!

> [@devans](#):
>
> We have tried simply omitting the password field but this gives us an error. Is there a different endpoint or method we can use to achieve the goal of getting an access\_token for a user without specifying their password?

Unfortunately, there really isn’t a solution within the supported OAuth and OIDC flows that allows for obtaining a user’s tokens with just an email in the way you’ve described. It seems like your best bet may utilizing the [Resource Owner Password Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow) (what you’re doing in the code shared) if it is being carried out by a highly trusted application.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 21, 2024, 11:52pm UTC](https://community.auth0.com/t/how-to-retrieve-access-token-for-user-with-only-email-client-id-and-client-secret/133611/4 "2024-05-21T23:52:07Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
