c# - The application named HTTPS://test113.onmicrosoft.com/FTP was not found in the tenant named test113.onmicrosoft.com -
i have authenticate application against azure ad. have created web api , added azure ad application section. changed manifest file, created web api , authenticated azure ad , created windows form, containing following code:
private async void button1_click(object sender, eventargs e) { string authority = "https://login.windows.net/test113.onmicrosoft.com"; string resourceuri = "https://test113.onmicrosoft.com/ftp"; string clientid = "5177ef76-cbb4-43a8-a7d0-899d3e886b34"; uri returnuri = new uri("http://keoftp"); authenticationcontext authcontext = new authenticationcontext(authority); authenticationresult authresult = authcontext.acquiretoken(resourceuri, clientid, returnuri); string authheader = authresult.createauthorizationheader(); // don't in prod system.net.servicepointmanager.servercertificatevalidationcallback = ((s, c, c2, se) => true); httpclient client = new httpclient(); httprequestmessage request = new httprequestmessage(httpmethod.get, "https://localhost:44300/api/tasks"); request.headers.tryaddwithoutvalidation("authorization", authheader); var response = await client.sendasync(request); string responsestring = await response.content.readasstringasync(); messagebox.show(responsestring); }
i have got exception:
an exception of type 'microsoft.identitymodel.clients.activedirectory.adalserviceexception' occurred in microsoft.identitymodel.clients.activedirectory.dll not handled in user code
additional information: aadsts50001: application named https://test113.onmicrosoft.com/ftp not found in tenant named test113.onmicrosoft.com. can happen if application has not been installed administrator of tenant or consented user in tenant. might have sent authentication request wrong tenant.
trace id: e782d60e-b861-46a3-b32b-f3df78396bd0 correlation id: b4809815-2755-4de1-bd1b-0221d74fd0f0 timestamp: 2016-03-17 11:20:08z
resource in request means resource want access in particular tenant. when native client needs token azure active directory, needs specify resource wants token for. in scenario client application wants access web api app id uri web api used resource name. after has token needs know url resource can accessed, in case address of web api.for example:
// resource settings application wants access private string resource = "https://cloudalloc.com/cloudalloc.webapi"; private uri webapiuri = new uri("https://localhost:44313");
both of these settings can found in single sign-on section of configure page web api application in azure management portal.
click here more details .
Comments
Post a Comment