Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up a Client Secret for a Native Client Application to access Azure Graph

Tags:

client

azure

I have developed a Native Client application that uses the Azure AD for authentication. I need to access some information using the AD Graph which requires a Client ID and Client Secret. I have added the application to my Azure active directory. I have added a reference to the Active Directory Authentication Library (ADAL) and installed the GraphAPI. The AquireToken of the Authentication context requires a Client ID (which I have) and a Client Secret (key), which I do not have. I have looked everywhere in the configuration of the application in the Azure portal and it appears that native applications do not have an option to set up a key. Web Apps do. Does anyone know how to set up and obtain a key for a Native Application?

like image 671
DavidC Avatar asked Jun 13 '14 18:06

DavidC


2 Answers

You should create a Web application for your purpose. That is how you can create a confidential client which has both ID and Secret. Azure portal will generate the secret for you.

like image 146
Afshin Avatar answered Nov 12 '22 14:11

Afshin


Native clients don't have the option to set up keys, only Web applications. I'm only new to this and stumbled upon the question because I was struggling with this myself. FYI, I have managed to use the Acquire Token successfully in the following way:

result = authContext.AcquireToken(ResourceId, clientId, redirectUri, PromptBehavior.Auto);

Where:
ResourceId e.g. https://examplename.onmicrosoft.com/ServiceName

clientId = e.g. 82692da5-a86f-44c9-9d53-2f88d52b478b

redirectUri = still haven't figured out how to use this but i used..
https://examplename.onmicrosoft.com/ServiceName

PromptBehavior.Always I set it as Always so I will always get the browser window to log in.

I hope this helps.

like image 43
slavs Avatar answered Nov 12 '22 14:11

slavs