我的問題是這樣的
我正試圖用angular-oauth2-oidc實作SSO和OAuth2流程。我可以使用POSTMAN和ThunderClient(VS代碼)獲得正確的回應(access_token),但Angular卻不行下面是我的配置:
authCodeFlowConfig。AuthConfig = {
issuer: 'https://URL.com/'。
loginUrl: 'https://URL.com/authorize-client',
clientId: environment.API.CLIENT_ID。
responseType: 'code',
scope: environment.API.SCOPE。
tokenEndpoint。'https://URL.com/request-access'。
dummyClientSecret: environment.API.CLIENT_SECRET。
redirectUri: window.location.origin,
showDebugInformation: true。
}
...
constructor()
private httpClient: HttpClient,
private oauthService: OAuthService
) {
this.getAuthorizeClientCode()
}
...
getAuthorizeClientCode() {
this.oauthService。 configure(this.authCodeFlowConfig) 。
this.oauthService。 tokenValidationHandler = new JwksValidationHandler()
this.oauthService.tryLogin({
onTokenReceived: context => {
console.log(text)
}
})
.then(() => {
if (this.oauthService.hasValidAccessToken() ) {
this.oauthService.silentRefresh()
} else {
this.oauthService.initCodeFlow()。
}
})
.catch(err => console.log(err)
}
發生了什么:該流程一直作業到一個點。
我到處搜尋,但沒有找到。
我到處搜索,我真的不知道我錯過了什么,因為這個流程在 POSTMAN 中可以作業,但在 Angular 中卻不行。
uj5u.com熱心網友回復:
你需要在后臺啟用cors,你可以在chrome上安裝這些工具來禁用它進行測驗
https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbchttps://轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/323561.html
標籤:
上一篇:如何用0%替換NULL%


