我正在尝试通过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(“” / *这里放什么* / )
答案 0 :(得分:0)
检查此 GitHub示例是否有助于您进行身份验证。它有3种方法来验证和获取具有详细指令的身份验证令牌。检查app.config以获取样本值和方法注释,以获取有关所需内容的详细信息。
链接到示例:Azure Authentication GitHub Sample
示例的相关博客:Azure Authentication - Authenticating any Azure API Request in your Application
答案 1 :(得分:0)
我相信你想要的两个端点是:
https://login.windows.net/{{tenantId}}/oauth2/authorize
https://login.windows.net/{tenantId}/oauth2/token
{tenantId}
是您的租户的GUID标识符。它也可能适用于您的域名,但我还没有检查过。