{"action":"opened","issue":{"url":"https://api.github.com/repos/AzureADSamples/WebApp-WebAPI-MultiTenant-OpenIdConnect-DotNet/issues/17","labels_url":"https://api.github.com/repos/AzureADSamples/WebApp-WebAPI-MultiTenant-OpenIdConnect-DotNet/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/AzureADSamples/WebApp-WebAPI-MultiTenant-OpenIdConnect-DotNet/issues/17/comments","events_url":"https://api.github.com/repos/AzureADSamples/WebApp-WebAPI-MultiTenant-OpenIdConnect-DotNet/issues/17/events","html_url":"https://github.com/AzureADSamples/WebApp-WebAPI-MultiTenant-OpenIdConnect-DotNet/issues/17","id":95462751,"number":17,"title":" How can I run my AAD graph api differential query application as multi-tenant?","user":{"login":"varnikhaasree","id":8028636,"avatar_url":"https://avatars.githubusercontent.com/u/8028636?v=3","gravatar_id":"","url":"https://api.github.com/users/varnikhaasree","html_url":"https://github.com/varnikhaasree","followers_url":"https://api.github.com/users/varnikhaasree/followers","following_url":"https://api.github.com/users/varnikhaasree/following{/other_user}","gists_url":"https://api.github.com/users/varnikhaasree/gists{/gist_id}","starred_url":"https://api.github.com/users/varnikhaasree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varnikhaasree/subscriptions","organizations_url":"https://api.github.com/users/varnikhaasree/orgs","repos_url":"https://api.github.com/users/varnikhaasree/repos","events_url":"https://api.github.com/users/varnikhaasree/events{/privacy}","received_events_url":"https://api.github.com/users/varnikhaasree/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-16T15:41:16Z","updated_at":"2015-07-16T15:41:16Z","closed_at":null,"body":"followed the same steps which is mentioned in the below GitHub sample to query graph api from my console application\r\nhttps://github.com/AzureADSamples/ConsoleApp-GraphAPI-DiffQuery-DotNet\r\n\r\nMainTenant - application is created under the MainTenant\r\n and I'm able to retrieve users from my console application with the below configuration \r\n\r\n<add key=\"TenantDomainName\" value=\"MainTenant.onmicrosoft.com\"/>\r\n  \r\n<add key=\"AppPrincipalId\" value=\"586d8f40-a2be-4e3c-99dc-9c31d0781920\"/>\r\n\r\n<add key=\"AppPrincipalPassword\" value=\"26ejww70hIoiVXwhLlrjta5XDvpBJ9ilvSb/kf711DQ=\"/>\r\n \r\n<add key=\"PullIntervalSec\" value=\"60\"/>\r\n\r\nBut if I try to retrieve users for other tenants I get the following error \r\nThe remote server returned an error: (401) Unauthorized.\r\nat System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)\r\n\r\n\r\nupdated my configuration for to get users from other tenant\r\n<add key=\"TenantDomainName\" value=\"SubTenant.onmicrosoft.com\"/>\r\n  \r\n<add key=\"AppPrincipalId\" value=\"586d8f40-a2be-4e3c-99dc-9c31d0781920\"/>\r\n\r\n<add key=\"AppPrincipalPassword\" value=\"26ejww70hIoiVXwhLlrjta5XDvpBJ9ilvSb/kf711DQ=\"/>\r\n \r\n<add key=\"PullIntervalSec\" value=\"60\"/>\r\n\r\nstring AuthEndpoint=\"https://login.windows.net/{0}\";\r\n\r\n\r\nretrieving the accesstoken from the below method is possible\r\n\r\n protected string GetTokenForApplication()\r\n        {\r\n            string aEndpoint = string.Format(AuthEndpoint, TenantDomainName);\r\n            AuthenticationContext authenticationContext = new AuthenticationContext(aEndpoint, false);\r\n            // Config for OAuth client credentials \r\n            ClientCredential clientCred = new ClientCredential(this.AppPrincipalId, this.AppPrincipalPassword);\r\n            AuthenticationResult authenticationResult = authenticationContext.AcquireToken(this.ProtectedResourcePrincipalId, clientCred);\r\n            return authenticationResult.AccessToken;\r\n        }\r\nbut it throws error when I execute the DownloadData method\r\n\r\n\r\n private byte[] DownloadData(WebClient webClient, string suffix)\r\n      \r\n {\r\n                this.AddHeaders(webClient);\r\n                string serviceEndPoint = string.Format(\r\n                    @\"https://{0}/{1}/{2}\",\r\n                    \"graph.windows.net\",\r\n                    TenantDomainName,\r\n                    suffix);\r\n\r\n                return webClient.DownloadData(serviceEndPoint);\r\n  }\r\nerror: The remote server returned an error: (401) Unauthorized.\r\nat System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)\r\n\r\ncould some one pls help me to fix this error\r\n\r\nthanks in advance"}}