【发布时间】:2016-11-30 06:32:51
【问题描述】:
我正在尝试通过 DotNetOpenAuth 库从 Azure AD 获取授权令牌。我不想使用 ADAL,因为我在 .net 3.5 中有一个庞大的项目,而 ADAL 不支持 .net 3.5(仅 .net > 4)。但是,我不能完全让它与 Azure AD 一起使用。我不知道要配置什么。到目前为止,这就是我所拥有的:
private static WebServerClient _webServerClient;
private static string _accessToken;
// Client ID (as obtained from Azure AD portal)
private static string clientId = "here goes my client id guid";
// Client Secret (as obtained from Azure AD portal)
private static string appKey = "here goes my secret";
private static string aadInstance = "https://login.microsoftonline.com/{0}";
private static string tenant = "mytenant.domain.com";
private static string authority = string.Format(CultureInfo.InvariantCulture, aadInstance, tenant);
// Azure AD resource I am trying to access
private static string serviceResourceId = "https://mytenant.domain.com/protectedresource";
private static void InitializeWebServerClient()
{
var authorizationServer = new AuthorizationServerDescription
{
AuthorizationEndpoint = new Uri(""/* WHAT TO PUT HERE */),
TokenEndpoint = new Uri(""/* WHAT TO PUT HERE */)
};
_webServerClient = new WebServerClient(authorizationServer, clientId, appKey);
}
private static void RequestToken()
{
var state = _webServerClient.GetClientAccessToken();
_accessToken = state.AccessToken;
}
static void Main(string[] args) {
InitializeWebServerClient();
RequestToken();
}
问题是我不知道该放什么。我不知道我应该在这里放置什么值:
AuthorizationEndpoint = new Uri(""/* 在这里放什么 */),
TokenEndpoint = new Uri(""/* 在这里放什么 */)
【问题讨论】:
标签: azure oauth-2.0 access-token dotnetopenauth azure-active-directory