I have deployed API App for Azure, but I am having problems creating the API client if authentication (with AAD) is set to ON.
When I try to create a service client (when authentication is turned off), then the client code is generated (it is executed using Autorest) and the code works, but when I turn ON authentication (and the action that needs to be performed when the request is not authenticated, set Login with Azure Active Directory ), then
1) 401 Unauthorized callback returned (without redirecting to the AAD login page)
2) Then I tried to create the service client again (from the context menu of Project → Add → REST API Client →, then in the dialog box I selected “Select Azure Asset” and clicked OK and received the message "Failed to download metadata file for Microsoft Azure API App: ...app name..." (and" no further information ")
I implemented AAD in accordance with this Azure guide (using express settings):
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-how-to-configure-active-directory-authentication/
Worked on this video too, and everything that was shown in this video worked, except that AAD was not shown ... and for me it does not work ...
https://azure.microsoft.com/en-us/documentation/videos/connect-2015-what-s-new-in-app-service-api-apps/
Any suggestions?
EDIT
1) If I enter the request URL (which uses the REST API client) in the web browser - then it returns real results 2) I found out that I use the REST API without credentials (I thought that should be presented in this case Azure AD login screen ... but it’s not)
EDIT 2
I have some progress - I got to the login screen in AAD, but after entering the credentials I got a bearer token , but when I try to execute a service request, I get an error message:
AADSTS65005: The client application has requested access to resource 'https....azurewebsites.net'. This request has failed because the client has not specified this resource in its requiredResourceAccess list. Trace ID: 4176e... Correlation ID: 1d612d... Timestamp: 2016-11-13 18:28:34Z
These are the steps I took to go this far:
0) Added Microsoft.IdentityModel.Clients.ActiveDirectory nuget package for client project
1) registered my client application in Azure Active Directory
2) when calling the REST API from the client application, I add ServiceClientCredentials
3) when creating ServiceClientCredentials, I provide 4 elements -authority = this is from AAD application registrations → Endpoints => Federation metadata document vērtība (without the initial part http://login.windows.net/ )
-resource => this is the REST API uri (=> The identifier of the target resource that is the recipient of the requested token)
-clientId => is the application identifier that I get after I register the client application in AAD -redirect Uri =>, since my client application is a native application, this is just any valid URL
How can I specify this resource in my client application?
client has not specified this resource in its requiredResourceAccess list