Reputation: 2055
How check token is valid?
I run this and later I get token but I would like to check is valid
@action
signIn() {
const loginRequest = {
scopes: ["User.ReadWrite"]
}
this.userAgentApplication.loginRedirect(loginRequest);
this._isLoggedIn = true;
}
Upvotes: 0
Views: 642
Reputation: 1602
In the app's registration screen, click on the API permissions blade in the left to open the page where we add access to the Apis that your application needs.
Click the Add a permission button and then, Ensure that the My APIs tab is selected. In the list of APIs, select the API TodoListService-ManualJwt. In the Delegated permissions section, select the Access 'TodoListService-ManualJwt' in the list. Use the search box if necessary. Click on the Add permissions button at the bottom.
public void ConfigureAuth(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
TokenValidationParameters = new TokenValidationParameters {
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
},
});
}
Please refer this document for token validation with web api
Upvotes: 1
Reputation: 2766
As per the documentation here: https://learn.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-sign-in?tabs=javascript#sign-in-with-redirect you need to register a callback function in order to access/process the tokens.
The redirect methods don't return a promise because of the move away from the main app. To process and access the returned tokens, you need to register success and error callbacks before you call the redirect methods.
function authCallback(error, response) {
//handle redirect response
}
myMsal.handleRedirectCallback(authCallback);
I think the token would likely be in the response somewhere.
Upvotes: 1