Answered by:
Azure AD Authentication for Web API

Question
-
User-1946294156 posted
I am following the below example:
The code will compile and deploy. However, the API Controller that I have tagged with Authorized, it will only tell me that I am not authorized. Is there a way to instead of having it state that I am not authorized, but redirect me to the Azure AD Login Prompt?
Thank you in advance for your help.
Saturday, May 12, 2018 3:38 PM
Answers
-
User475983607 posted
Web API does not have a UI. Your web application must handle the authentication.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 12, 2018 4:01 PM -
User1724605321 posted
Hi bobj181,
As a supplement, you can refer to Authentication scenarios for Azure AD and choose the scenarios base on your requirement :
To web api ,special scenario(on-behalf-of flow) is :
A user has authenticated on a native application, and this native application needs to call a web API. Azure AD issues a JWT access token to call the web API. If the web API needs to call another downstream web API, it can use the on-behalf-of flow to delegate the user’s identity and authenticate to the second-tier web API :
https://github.com/Azure-Samples/active-directory-dotnet-webapi-onbehalfof
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 14, 2018 9:00 AM
All replies
-
User475983607 posted
Web API does not have a UI. Your web application must handle the authentication.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 12, 2018 4:01 PM -
User1724605321 posted
Hi bobj181,
As a supplement, you can refer to Authentication scenarios for Azure AD and choose the scenarios base on your requirement :
To web api ,special scenario(on-behalf-of flow) is :
A user has authenticated on a native application, and this native application needs to call a web API. Azure AD issues a JWT access token to call the web API. If the web API needs to call another downstream web API, it can use the on-behalf-of flow to delegate the user’s identity and authenticate to the second-tier web API :
https://github.com/Azure-Samples/active-directory-dotnet-webapi-onbehalfof
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 14, 2018 9:00 AM