Using ms-adal-angular6 package, we are not able to get the authorization code from the sign-in request oauth2/authorize. The app can use the authorization code to request an access token for the target resource. The response_type query parameter in the sign-in request is hard-coded to have value 'id_token' only. So in-order to get authorization code, there should be change in response_type parameter value in our sign-in request. The value should be response_type=id_token+code. Thus the request will return your app an authorization code to exchange for an access token.
// Line breaks for legibility only
GET https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx // Your registered Application ID
&response_type=id_token+code
&redirect_uri=http%3A%2F%2Flocalhost%3a4200 // Your registered Redirect Uri, url encoded
&response_mode=form_post // `form_post' or 'fragment'
&scope=openid
&resource=https%3A%2F%2Fservice.app.com%2F // The identifier of the protected resource (web API) that your application needs access to
&state=12345 // Any value, provided by your app
&nonce=678910 // Any value, provided by your app``
It would be better to set the response_type value in our configuration settings and thus we can remove the hard-coded values such as id_token. Do the needful to get the authorization code from the sign-in request.
Using ms-adal-angular6 package, we are not able to get the authorization code from the sign-in request oauth2/authorize. The app can use the authorization code to request an access token for the target resource. The response_type query parameter in the sign-in request is hard-coded to have value 'id_token' only. So in-order to get authorization code, there should be change in response_type parameter value in our sign-in request. The value should be
response_type=id_token+code
. Thus the request will return your app an authorization code to exchange for an access token.See the official documentation here https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-openid-connect-code#get-access-tokens
See the sign-in request sample for more details.
It would be better to set the response_type value in our configuration settings and thus we can remove the hard-coded values such as
id_token
. Do the needful to get the authorization code from the sign-in request.