我正在尝试将aws cognito与angular6一起使用。证明是一场灾难
我使用google auth,并在浏览器URL中获得以下内容。 congnito成功重定向到我的页面。大。现在呢?
http://localhost:4200/#id_token=eyJraWQiOiJhTXRTYko0VDJreStHRnBCQWg5K3JLZmt5QWvwt9yE_rNmja9mh6gMCDOy0g3JPC1WkwjEmU9YdEW5MQqHAurYUoidAHCB6GjEHBob-1O_bu_hLowhDCucWVeCzhfMNw&access_token=eyJraWQiOiJLMTZ1ZmVURWE1dmRPamU5aTJReXkycGVDWnVQeE1TR1p5VWZwV3NvaEM4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI3YTgxNmU0Yi0zMTVkLTRkMmMtOWFhYS04MzIzNWFjMWU1NWUiLCJjb2duaXRvOmdyb3VwcyI6WyJ1cy1lYXN0LTFfYmx6dFlsImp0aSI6IjAwNjJhODI1LTVmMmEtNDZkNi04N2FlLTkzYTc5MTlhMDVkMyIsImNsaWVudF9pZCI6IjNlMGR1YWdwY3NoMmdhNmRkbm5lNXI4ajltIiwidXNlcm5hbWUiOiJHb29nbGVfMTE2MDA1Nzg1NjQ1MjgzNTEyMjM2In0.dwlRhohhYYUmgIpH7H8kgOV6W4k_E3nv-ty0tnHD043dErrliUKxST-7Sj0zzHCfe6JrUJv417vlU3sD1BYs6bMYKFoygdWp7RMuAQXC8o6TqHEpviOHwElVgVEQ0JY9twui3q_2mOL7yoKlWdax8c46sGtaLILRdm0YSoI0gGqwCYCCgWT4LZ424wdRVxJtBfB-gXKmQr6Z24Co7-7-9aDaYRiVMrFRywTwY_mxuViEZYQ9JJ432_d-EgYp9zfsATNQ26Iaol50Sdq36UL_kfWrnXaJR-itkfwLLAtDj-kTQCUYM3vfzF65E7f0IFHNqc0MAWB5O8wZoWpr_FI9iQ&expires_in=3600&token_type=Bearer
#id_token=eyJraWQ....
处理了什么?我得到查询字符串returns {}
this.route.queryParams.subscribe(params => {
console.log(params)
})
如何在Angular中访问?
我尝试了以下操作:
import {AuthenticationDetails, CognitoUser, CognitoUserAttribute, CognitoUserPool} from 'amazon-cognito-identity-js';
import * as AWS from 'aws-sdk';
const PoolData = {
UserPoolId: "us-east-1_sgsdfgsfd",
ClientId: "3e0d5r8j9m"
};
const userPool = new CognitoUserPool(PoolData);
var cognitoUser = userPool.getCurrentUser();
如果我使用RouterModule.forRoot(ROUTES, { useHash: true })
,则会收到以下错误。所以我必须设置为false
core.js:1624 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'id_token'
Error: Cannot match any routes. URL Segment: 'id_token'
Net Net ...
cognitoUser返回null
这让我无处可去。
如何创建cognitoUser?还是至少得到jwt in token_id
?