带有 OIDC 和 Azure AD 的代码流 PKCE 在 /token 端点上出现 cors 错误
Code flow PKCE with OIDC and Azure AD get cors error on /token endpoint
我看到新建议(自 2019 年年中以来)是将代码流与 PKCE 结合使用,而不是 SPA 的隐式流。我有一个 angular spa,它使用 OIDC 客户端并且工作正常,直到它调用 /token 端点 return cors 错误
Access to XMLHttpRequest at 'https://login.microsoftonline.com/xxx/oauth2/token' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested
有没有办法克服这个错误,或者有没有办法在 Azure AD 中配置允许的来源 (CORS) 还是我做错了什么?
无法在 Azure AD 中配置允许的来源。
所以有两种解决方案:
1.Use MSAL.js 与 Azure AD B2C。
2.Call 服务器中的 /token 端点,然后您可以向您的服务器发出请求。
参考:
我看到新建议(自 2019 年年中以来)是将代码流与 PKCE 结合使用,而不是 SPA 的隐式流。我有一个 angular spa,它使用 OIDC 客户端并且工作正常,直到它调用 /token 端点 return cors 错误
Access to XMLHttpRequest at 'https://login.microsoftonline.com/xxx/oauth2/token' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested
有没有办法克服这个错误,或者有没有办法在 Azure AD 中配置允许的来源 (CORS) 还是我做错了什么?
无法在 Azure AD 中配置允许的来源。
所以有两种解决方案:
1.Use MSAL.js 与 Azure AD B2C。
2.Call 服务器中的 /token 端点,然后您可以向您的服务器发出请求。
参考: