我正在尝试实现下面的链接中的内容。有人能告诉我如何使用此令牌访问安全的第三方API吗?
例如:我的web应用程序在http://localhosthost:8080/ui/,Web在http://localhosthost:8080/rest-api/
我仍然没有看到任何附加在请求中的令牌。
以下是我的代码
app.config(['$routeProvider', '$httpProvider', 'adalAuthenticationServiceProvider', function ($routeProvider, $httpProvider,
adalAuthenticationServiceProvider) {
$routeProvider
.when("/", {templateUrl: "partials/package.html", requireADLogin: true,})
.when("/dashboard", {templateUrl: "partials/package.html", controller: "searchCtrl", requireADLogin: true,})
.when("/create", {templateUrl: "partials/upload.html", controller: "packageCtrl", requireADLogin: true,})
$routeProvider.otherwise({ redirectTo: "/home" });
var endpoints = {
// Map the location of a request to an API to a the identifier of the associated resource
"http://localhost:8081/rest-api/":
"http://localhost:8081/rest-api/",
};
adalAuthenticationServiceProvider.init(
{
tenant: 'common',
clientId: '',
extraQueryParameter: 'nux=1',
endpoints: endpoints
},
$httpProvider
);}]);
发布于 2017-05-09 05:08:23
如果您仅使用单个AAD服务器进行身份验证,则需要将API url映射到客户端id令牌:
var clientId = 'some guid';
var endpoints = {
"http://localhost:8081/rest-api/": clientId,
};
adalAuthenticationServiceProvider.init(
{
tenant: 'common',
clientId: clientId,
extraQueryParameter: 'nux=1',
endpoints: endpoints
},
$httpProvider
);这告诉ADAL针对与属性名称匹配的URL的HTTP请求,使用存储在右侧密钥下的持有者令牌。
我建议查看ADAL函数getResourceForEndpoint (从v1.0.14开始)-此函数输出确定ADAL-angular是否将身份验证头附加到请求,以及使用哪个承载令牌。
发布于 2015-03-10 03:06:39
端点用于不同主机上的CORS api请求。您可以在此处查看示例https://github.com/AzureADSamples/SinglePageApp-WebAPI-AngularJS-DotNet
ADAL.js比较端点以附加CORS api调用的令牌。
您的服务终结点url可能与指定的终结点不同。您可以在adal-angular.js的ProtectedResourceInterceptor中看到令牌附加逻辑
https://stackoverflow.com/questions/28942189
复制相似问题