Azure B2C with msal-autentication-android and custom policy. expires_in is missing

Hristo Stoev 1 Reputation point
2021-02-10T08:12:16.937+00:00

I ma tiring to configure Azure B2C authentication for android. I am using https://github.com/AzureAD/microsoft-authentication-library-for-android . With the default user flow i am getting exception from the msal lib, because of a missing claim in the token. So i've been advised to configure custom policy - https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-get-started . However i am still not able to get expires_in claim in the JWT token.

https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/1295
My token looks like :

{  
"id_token": "eyJ0eX5MmE0LTdlMz...",  
"token_type": "Bearer",  
"not_before": 1612880617,  
"client_info": "eyJ1aWQiOiI3NWU1ZjNjYi01....",  
"scope": "",  
"refresh_token": "eyJraWQiOiJBanNhY..."  
}  

where it should look like :

{  
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",  
    "token_type": "Bearer",  
    "expires_in": 3599,  
    "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",  
    "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",  
    "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",  
}  

so how can i configure B2C authentication to work properly with msal authentication lib ? Or in other words, how can I customize the JWT issuer , to issue needed token ?

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,473 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,306 Reputation points
    2021-02-15T07:11:19.54+00:00

    Hi @Hristo Stoev · Glad to see that your issue is resolved. Posting the solution here so that it helps others in the community who are facing the similar issue.

       <TechnicalProfile Id="JwtIssuer">  
       ...  
       <Metadata>  
       ....  
                   <Item Key="token_lifetime_secs">3680</Item>  
                   <Item Key="id_token_lifetime_secs">3601</Item>  
                   <Item Key="refresh_token_lifetime_secs">86400</Item>  
                   <Item Key="rolling_refresh_token_lifetime_secs">86401</Item>  
                 </Metadata>  
    
    0 comments No comments