how to get an access token using angular MSAL
up vote
1
down vote
favorite
Background:
I am trying to get an angular SPA to work with a Postgrest API backend, using Azure Active Directory as the identity provider for getting a JWT. The test app works using Auth0 -- I am able to authenticate a user, get an access token, pass that token to the postgrest backend, it validates the token, checks the user's group and then allows access. My issue is when I switch out from Auth0 to Azure AD.
To start with I've switched out the Auth0 code to MSFT's msal-angular library
This works a little bit. I can secure a custom component with a guard. Navigation to the component prompts for an Azure AD login, and my test app successfully gets an identity token back.
When I go hit the API backend the MSAL interceptor successfully puts a Bearer token into the headers -- though not a usable token as this is the identity token not the access token.
My Question:
According to the MSFT docs on using OAuth Implicit flow I need to set the response_type to both id_token and token.
However I can not find any way in the MSAL for Angular documentation on how to do that.
Is it possible?
angular jwt
add a comment |
up vote
1
down vote
favorite
Background:
I am trying to get an angular SPA to work with a Postgrest API backend, using Azure Active Directory as the identity provider for getting a JWT. The test app works using Auth0 -- I am able to authenticate a user, get an access token, pass that token to the postgrest backend, it validates the token, checks the user's group and then allows access. My issue is when I switch out from Auth0 to Azure AD.
To start with I've switched out the Auth0 code to MSFT's msal-angular library
This works a little bit. I can secure a custom component with a guard. Navigation to the component prompts for an Azure AD login, and my test app successfully gets an identity token back.
When I go hit the API backend the MSAL interceptor successfully puts a Bearer token into the headers -- though not a usable token as this is the identity token not the access token.
My Question:
According to the MSFT docs on using OAuth Implicit flow I need to set the response_type to both id_token and token.
However I can not find any way in the MSAL for Angular documentation on how to do that.
Is it possible?
angular jwt
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Background:
I am trying to get an angular SPA to work with a Postgrest API backend, using Azure Active Directory as the identity provider for getting a JWT. The test app works using Auth0 -- I am able to authenticate a user, get an access token, pass that token to the postgrest backend, it validates the token, checks the user's group and then allows access. My issue is when I switch out from Auth0 to Azure AD.
To start with I've switched out the Auth0 code to MSFT's msal-angular library
This works a little bit. I can secure a custom component with a guard. Navigation to the component prompts for an Azure AD login, and my test app successfully gets an identity token back.
When I go hit the API backend the MSAL interceptor successfully puts a Bearer token into the headers -- though not a usable token as this is the identity token not the access token.
My Question:
According to the MSFT docs on using OAuth Implicit flow I need to set the response_type to both id_token and token.
However I can not find any way in the MSAL for Angular documentation on how to do that.
Is it possible?
angular jwt
Background:
I am trying to get an angular SPA to work with a Postgrest API backend, using Azure Active Directory as the identity provider for getting a JWT. The test app works using Auth0 -- I am able to authenticate a user, get an access token, pass that token to the postgrest backend, it validates the token, checks the user's group and then allows access. My issue is when I switch out from Auth0 to Azure AD.
To start with I've switched out the Auth0 code to MSFT's msal-angular library
This works a little bit. I can secure a custom component with a guard. Navigation to the component prompts for an Azure AD login, and my test app successfully gets an identity token back.
When I go hit the API backend the MSAL interceptor successfully puts a Bearer token into the headers -- though not a usable token as this is the identity token not the access token.
My Question:
According to the MSFT docs on using OAuth Implicit flow I need to set the response_type to both id_token and token.
However I can not find any way in the MSAL for Angular documentation on how to do that.
Is it possible?
angular jwt
angular jwt
asked Nov 10 at 18:18
BVD
61
61
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53
add a comment |
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242022%2fhow-to-get-an-access-token-using-angular-msal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share the code you're using currently, which is providing the unexpected behavior?
– Philippe Signoret
Nov 12 at 12:53