Azure 使用ADAL进行身份验证
我正在使用以下代码验证Azure试用帐户中的默认用户Azure 使用ADAL进行身份验证,azure,azure-active-directory,Azure,Azure Active Directory,我正在使用以下代码验证Azure试用帐户中的默认用户 static void Main(string[] args) { GetTokenAsync().Wait(); } static async Task<string> GetTokenAsync() { string Tenant = "mytest.onmicrosoft.com"; string Authority = "https:
static void Main(string[] args)
{
GetTokenAsync().Wait();
}
static async Task<string> GetTokenAsync()
{
string Tenant = "mytest.onmicrosoft.com";
string Authority = "https://login.microsoftonline.com/" + Tenant;
string GatewayLoginUrl = "https://login.microsoftonline.com/something/wsfed";
string ClientId = "something";
Uri RedirectUri = new Uri("http://something");
AuthenticationContext context = new AuthenticationContext(Authority);
PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Auto, null);
AuthenticationResult result = await context.AcquireTokenAsync(GatewayLoginUrl, ClientId, RedirectUri, platformParams);
return result.ToString();
}
static void Main(字符串[]args)
{
GetTokenAsync().Wait();
}
静态异步任务GetTokenAsync()
{
字符串Tenant=“mytest.onmicrosoft.com”;
字符串权限=”https://login.microsoftonline.com/“+承租人;
字符串GatewayLoginUrl=”https://login.microsoftonline.com/something/wsfed";
字符串ClientId=“something”;
Uri重定向Uri=新Uri(“http://something");
AuthenticationContext=新的AuthenticationContext(授权);
PlatformParameters platformParams=新的PlatformParameters(PromptBehavior.Auto,null);
AuthenticationResult=await context.AcquireTokenAsync(GatewayLoginUrl、ClientId、RedirectUri、platformParams);
返回result.ToString();
}
我想知道从何处获取这些值:
- 房客
- 权威
- 门道酒店
- 客户
- 重定向URI
对于使用AD的用户身份验证来说,这么多代码就足够了吗?在使用Azure Active Directory保护应用程序时,有几种情况(请参阅): 以下是Azure AD支持的五个主要应用程序场景:
static void Main(string[] args)
{
GetTokenAsync().Wait();
}
static async Task<string> GetTokenAsync()
{
string Tenant = "mytest.onmicrosoft.com";
string Authority = "https://login.microsoftonline.com/" + Tenant;
string GatewayLoginUrl = "https://login.microsoftonline.com/something/wsfed";
string ClientId = "something";
Uri RedirectUri = new Uri("http://something");
AuthenticationContext context = new AuthenticationContext(Authority);
PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Auto, null);
AuthenticationResult result = await context.AcquireTokenAsync(GatewayLoginUrl, ClientId, RedirectUri, platformParams);
return result.ToString();
}
static void Main(字符串[]args)
{
GetTokenAsync().Wait();
}
静态异步任务GetTokenAsync()
{
字符串Tenant=“mytest.onmicrosoft.com”;
字符串权限=”https://login.microsoftonline.com/“+承租人;
字符串GatewayLoginUrl=”https://login.microsoftonline.com/something/wsfed";
字符串ClientId=“something”;
Uri重定向Uri=新Uri(“http://something");
AuthenticationContext=新的AuthenticationContext(授权);
PlatformParameters platformParams=新的PlatformParameters(PromptBehavior.Auto,null);
AuthenticationResult=await context.AcquireTokenAsync(GatewayLoginUrl、ClientId、RedirectUri、platformParams);
返回result.ToString();
}
是AAD域的名称,看起来您对了Tenant
为权限
,看来你也做对了”https://login.microsoftonline.com/“+Tenant
是您要保护的应用程序的应用程序Id UriGatewayLoginUrl
是本机应用程序的应用程序IdClientId
是本机应用程序的重定向UriRedirectUri
GatewayLoginUrl
访问要保护的应用程序的本机应用程序:
您可以从这里获得ClientId
和RedirectUri
其他参考资料
您可以看到本机应用程序的完整演练
有关使用本机应用程序访问受AAD保护的应用程序的全局概述,请参阅使用Azure Active Directory保护应用程序时,有几个场景(请参阅): 以下是Azure AD支持的五个主要应用程序场景:
static void Main(string[] args)
{
GetTokenAsync().Wait();
}
static async Task<string> GetTokenAsync()
{
string Tenant = "mytest.onmicrosoft.com";
string Authority = "https://login.microsoftonline.com/" + Tenant;
string GatewayLoginUrl = "https://login.microsoftonline.com/something/wsfed";
string ClientId = "something";
Uri RedirectUri = new Uri("http://something");
AuthenticationContext context = new AuthenticationContext(Authority);
PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Auto, null);
AuthenticationResult result = await context.AcquireTokenAsync(GatewayLoginUrl, ClientId, RedirectUri, platformParams);
return result.ToString();
}
static void Main(字符串[]args)
{
GetTokenAsync().Wait();
}
静态异步任务GetTokenAsync()
{
字符串Tenant=“mytest.onmicrosoft.com”;
字符串权限=”https://login.microsoftonline.com/“+承租人;
字符串GatewayLoginUrl=”https://login.microsoftonline.com/something/wsfed";
字符串ClientId=“something”;
Uri重定向Uri=新Uri(“http://something");
AuthenticationContext=新的AuthenticationContext(授权);
PlatformParameters platformParams=新的PlatformParameters(PromptBehavior.Auto,null);
AuthenticationResult=await context.AcquireTokenAsync(GatewayLoginUrl、ClientId、RedirectUri、platformParams);
返回result.ToString();
}
是租户