Due to some technical constraints, we are doing Username/Password AAD authentication when user login.
Users will input their username and password into our custom login page and our application calls IPublicClientApplication.AcquireTokenByUsernamePassword.
I'm planning to use the returned token to call another Web API application(also connecting to the same AAD). In the Web API application, I did the following:
Added the following code in startup
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme).AddAzureADBearer(options => Configuration.Bind("AzureAd", options));
include the following settings in my appsettings.json file
"AzureAd": { "Instance": "https://login.microsoftonline.com/", "ClientId": "<Application ID>", "TenantId": "<Tenant ID>" }
- Secure my web api using [Authorize]
I then use Postman to construct a call to the Web API based on the returned token. I included Authorization: Bearer <JWT Token>
. The Web API returns
Bearer error="invalid_token", error_description="The signature is invalid"
My questions are
- Can Web API application validate the username/password acquired token?
- If the token can be validated in Web API application, how can I do it since I'm getting the above error?