AWS Cognito社交登录

时间:2018-08-13 05:28:08

标签: amazon-web-services amazon-cognito google-authentication google-login

我已将Google登录信息集成到我的认知池。 我按照https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html中的步骤来实现。 成功通过身份验证后,用户将使用唯一的“代码”重定向到配置的url。

这是authroization_code。 下一步是将授权代码交换为“ token_id”。 我正在按照https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html中的步骤进行操作。 但是,当我发送交换令牌的请求时,得到的响应为“错误:invalid_client”

我已经重新检查了配置,但是找不到问题。 这是交换请求的示例

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://<mydomain>.auth.ap-south-1.amazoncognito.com/oauth2/token",
  "method": "POST",
  "headers": {
    "content-type": "application/x-www-form-urlencoded",
    "authorization": "Basic <clientid and secret from google (base 64 encoded)>",
    "cache-control": "no-cache",
    "postman-token": "af8e15qw-fdse-i78i-13dv-4faf33b12d12"
   },
  "data": {
    "grant_type": "authorization_code",
    "client_id": "<Client_id from cognito pool>",
    "redirect_uri": "https://google.com",
    "code": "<authorization_code>"
   }
 }

$.ajax(settings).done(function (response) {
  console.log(response);
});

0 个答案:

没有答案