我已经在Azure中为Microsoft Identity平台注册了一个应用程序。我将其配置为允许使用MS帐户(例如Outlook.com),并且基本上已经完成了一些在线快速入门here和here的所有操作(“向Web应用程序添加凭据”除外)。我还选中了启用隐式流程的框。
我将我的React应用程序重定向到URL进行登录(使用隐式流),我输入了用户名,但随后看到了
unauthorized_client:该客户端不存在或未为使用者启用。如果您是应用程序开发人员,请通过位于https://go.microsoft.com/fwlink/?linkid=2083908
的Azure门户中的“应用程序注册”来配置新应用程序
就像我上面提到的那样,我经历了几个快速入门,并了解了隐式流here并遵循了我的代码示例。
我还尝试了删除应用程序注册并重新开始。没有运气。
将浏览器重定向到一个网址的JS代码,该网址类似于Microsoft在其implicit flow page上的第一个示例
goSignIn() {
const tenant = 'common'; // (for us with MS accounts)
const clientId = '*****';
const redir = encodeURIComponent('http://localhost:3000/signin');
const nonce = Math.round(Math.random() * 10000, 0);
const uriTemplate = 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?client_id={clientId}&response_type=id_token+token&redirect_uri={redirect}&scope=openid&response_mode=fragment&state={state}&nonce={nonce}';
const filledTemplate = uriTemplate
.replace('{tenant}', tenant)
.replace('{clientId', clientId)
.replace('{redirect}', redir)
.replace('{nonce}', nonce)
.replace('{state}', nonce);
console.log(filledTemplate);
window.location = filledTemplate;
}
Azure->身份->应用程序注册-> MyApp->身份验证
Azure->身份->应用程序注册-> MyApp-> API权限
从我阅读的文档中,我认为我已经对id令牌做了足够的工作。我不确定必须进行哪些调整才能使其正常工作。
答案 0 :(得分:0)
您似乎已经做了足够的工作来获取令牌。我已经对此进行了测试,效果很好。在这里,我为您提供了我的屏幕截图,供您再次检查。
此外,这是我的工作请求网址,您可以使用msa登录进行测试。
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=5fd66168-7ba3-4bbc-a155-bff662eed9f7
&response_type=id_token+token
&redirect_uri=http://localhost:3000/signin
&scope=openid
&response_mode=fragment
&state=12345
&nonce=678910