msal angular getting id_token instead of access_token while calling the api - msal

Need to call .net core webapi from angular 10 application using msal angular.
Able to get the access token from this.msalService.acquireTokenSilent(scope), validated the access token using jwt.io. But on calling of webapi, the access_token is getting replaced by id_token.
Any idea why is this happening, Am stuck in this issue for past 1 week.
"#azure/msal-angular": "^1.1.1",
"msal": "^1.4.2",
.NetCore 3.1
Angular 10

Related

Blazor WebAssembly was released with token auth for the client side, does anyone know the REST URLs for login, register etc.?

Blazor WebAssembly officially shipped and the project includes token authentication with identity on the client side.
Does anyone know the Rest URLS to register, login and get tokens? I'm trying to test with postman but can't seem to track the Rest URLS down for the project.

wsfed authentication in webapp-webapi

The issue I am facing is to get webApi authenticated with bearer token received from webapp authentication.
Created web app, Angular template of .net core 2.1. Aded WsFed authentication to it. https://demoapp (dummy name)
Created Web Api app. Added wsfed authentication to it. https://demoapp-api (dummy name)
Now target is to authenticate web app, use token from there to make calls to api, and get data.
In WebApp, in OnTicketReceived WsFederationEvent, acquiring token using AcquireTokenAsync(AppId, credential);
Doing this because, we receive SAML token from WsFed.
Here tried with AppId of WebAPI, and also of WebApp. Both tokens do not work.
Passing this token as Bearer token in header to API.
When hitting API, facing redirection for authentication.
Ideally, when sending token, it should be allowed, right ?
I have added permissions of WebAPI on WebAPP in Azure portal, and also vice-versa.
Acquiring token using AppSecret.
Am I missing something here ? Or I am trying to achieve something which is not possible with WsFed ?
Can anyone please help with this webapp-webapi-wsfed scenario ?

Using Azure AD token in AJAX call from MVC application to separate WebAPI application

I have created a Azure AD protected .Net Core 2.0 WebAPI that has its own URL, and using same clientID, tenantID and domain I am able to send AJAX call from a SPA using ADAL JS.
Now, I need to implement the same without the use of ADAL JS in a MVC application. The issue I am facing is that the token generated by OIDC is not getting authorized on the separate API app.
Any suggestions for this scenario?

Ionic2 cloud google login with asp.net web api

I am building an ionic2 app and implemented google login flow. Which works fine and i get the token after a success full. How do i use this token to authenticate my project web api Endpoint ( using Oauth for generating the tokens). I am using default asp.net web api project template

Secure WebAPi, Windows Phone and MVC Website

I am working on a Windows Phone 8 app and a ASP.NET MVC 5 website and each of these will access a WebApi service (WebApi 2). The website and WebApi are based on the templates provided by VS2013 RTM and have been setup using the "Individual Account" authentication option available in the project template.
The template sets up the WebApi project to enable bearer tokens, application cookies and external login cookies, etc, and the exposed actions have the Authorize attribute on them.
My two questions are:
1) If I were to use Azure Mobile Services to authenticate a user using Google/Twitter on the WP8 application how can I get the WebApi to allow the authenticated user to access the actions?
2) Same as #1, but from a ASP.NET MVC 5 website perspective?
From I what I can see it would appear that each request requires a bearer token. To get this token would I be correct in thinking that I would access the "token" endpoint exposed by the WebApi to get the token and that would need to be passed with each request?
For 1, you can use azure mobile service WP8 sdk to launch a browser control to authorize user from external site. The code should be similar with WebAuthenticationBroker in windows store app.
For 2, the web api template with individual auth is using an implicit flow in OAuth 2.0 to return the application access token back to client. In MVC app, you can redirect user to
http://<web api domain address>/api/account/externallogin?provider=Facebook&redirect_uri=<your callback url in MVC app>&response_type=token&client_id=mvc.
And in your MVC view, you need to use javascript to get access token from url fragment, which won't be sent to server. In your web api server, you need to allow the client id and the callback url in ApplicationOAuthProvider.
For both 1 and 2, you are not using token endpoint to get the token. You are using the authorize endpoint to get token by implicit flow.

Resources