Azure AD B2C - access_token missing

Olivier Ragain 16 Reputation points
2020-10-22T18:53:21.007+00:00

Hi,
I've been testing Azure AD B2C and I have setup:
* IDProvider - tested and works
* User Flow
* Application

However, whether I try to do it via the Drupal website, or manually by doing get/post requests to the endpoints, I am unable to obtain an access_token. The answer from the token endpoint for the specific user flow (policy) only contains:
* id_token
* token_type (bearer)
* not_before
* id_token_expires_in
* profile_info
* scope (openid offline_access)
* refresh_token
* refresh_token_expires_in

but no access_token, when decoding the id_token again I only get:
{
"typ": "JWT",
"alg": "RS256",
"kid": "X5eXk4xyojNFum1kl2Ytv8dlNP4-c57dO6QGTVBwaNk"
}.{
"exp": 1603395300,
"nbf": 1603391700,
"ver": "1.0",
"iss": "https://<tenant>.b2clogin.com/GUID/v2.0/",
"sub": "GUID",
"aud": "GUID",
"nonce": "1236",
"iat": 1603391700,
"auth_time": 1603391521,
"idp": "IDP ID",
"given_name": "GN",
"family_name": "FN",
"oid": "my oid",
"emails": [
"my email"
],
"tfp": "policy name / user workflow"
}.[Signature]

Still no access_token.

All the microsoft documentations show access_token but no id_token:
https://learn.microsoft.com/en-us/azure/active-directory-b2c/openid-connect
https://learn.microsoft.com/en-us/azure/active-directory-b2c/access-tokens

Did I miss a step in the configuration of Azure AD B2C for it to add an access_token?

Thanks

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,951 Reputation points Moderator
    2020-10-23T06:25:39.827+00:00

    Hi @Olivier Ragain · The response that you get from B2C depends on the response type and scope parameter that you pass in the request.

    Please refer to below request to get an access token from Azure AD B2C:

    https://your_tenant.b2clogin.com/your_tenant.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1A_signup_signin&client_id=2c9296bb-xxxx-xxxx-xxxx-30d38790dea1&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=2c9296bb-xxxx-xxxx-xxxx-30d38790dea1&response_type=token&prompt=login  
    

    Here, I have updated below parameters to get Access Token:

    • scope=2c9296bb-xxxx-xxxx-xxxx-30d38790dea1
    • Response_type=token

    Also, make sure that you have enabled Access token for the application whose app id you are passing in the client_id paramter of your request. Refer to below screenshot for this purpose

    34553-image.png

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

  2. Michael Freidgeim 46 Reputation points
    2021-03-30T12:50:04.467+00:00

    I am following https://learn.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow#2-get-an-access-token and had the same issue as above: getting an id_token returned, but not an access_token..
    I finally found that when I specify ‘openid’ in scope, only ‘id_token’ is returned instead of expected both access_token and id_token.

    I am not sure, is it a bug or an expected behavior, that not clearly documented.

    @AmanpreetSingh-MSFT , can you advice how it should be reported?


  3. Som Borivong 0 Reputation points
    2023-04-23T01:48:18.8533333+00:00

    Doing some additional research off this article, if you specify "code" and "id_token" and "token" in the response type, then you will get the authorization code, ID token, and access token in the JWT.

    &client_id=00000000-0000-0000-0000-000000000000 &nonce=defaultNonce &redirect_uri=https%3A%2F%2Fjwt.ms &scope=openid offline_access 00000000-0000-0000-0000-000000000000 &response_type=code id_token token &prompt=login


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.