我正在尝试使用AD服务从react应用程序进行身份验证,并将令牌发送到我的.Net Core以使用[Authorize]属性,但正如我所知,我在这里获得的令牌只是用于对图表进行身份验证API。
有没有办法让令牌用作“auth”标头来调用我的API?
JS:
this.userAgentApplication = new UserAgentApplication(config.appId, null, null);
var access_token = this.userAgentApplication.acquireTokenSilent(config.scopes);
然后我得到access_token并作为“授权”标题发送到我的后端,其值为“Bearer $ {access_token}”
您必须通过config.scopes
指定您想要API的访问令牌。
你可以用例如
api-client-id-here/.default
或者代替.default,您可以指定您在API上定义的范围。如果需要多个范围,可以指定其中的多个。