简体   繁体   English

一旦 AWS Cognito 身份验证,我们如何获得 facebook 访问令牌?

[英]How we can get the facebook access token once the AWS Cognito authentication?

I am integrate the my application with AWS Cognito user pool and authentication provider as Facebook.我将我的应用程序与 AWS Cognito 用户池和身份验证提供程序集成为 Facebook。

Configured the aws user pool with facebook ap id.使用 facebook ap id 配置 aws 用户池。

I am using aws cognito user pool in code base, using aws-amplify able to get the facebook login page and authentication is happening and getting successfully redirect to my app.我在代码库中使用 aws cognito 用户池,使用aws-amplify能够获取 facebook 登录页面并且正在进行身份验证并成功重定向到我的应用程序。

I am Getting facebook user id from Auth.currentAuthenticateuser/currenSession .我正在从Auth.currentAuthenticateuser/currenSession获取 facebook 用户 ID。

It has the 3 tokens as well id, access, refresh.它有 3 个令牌以及 id、access、refresh。 but need fb acc_token to get data from facebook API like user permissions.但需要fb acc_token从facebook API获取数据,比如用户权限。

any way to get facebook access token after aws cognito user pool authentication? aws cognito 用户池身份验证后有什么方法可以获取 facebook 访问令牌?

Hub.listen("auth", async ({payload}) => {

    const resp = await fetch(`https://graph.facebook.com/oauth/access_token?client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&grant_type=client_credentials`)
    const access_token = (await resp.json()).access_token

    const facebookId = payload.data.username.split('_')[1];
    const userResp = await fetch(
        `https://graph.facebook.com/${facebookId}?access_token=${access_token}&fields=id,name,email,first_name,last_name,picture`
      );
    
    const user = await userResp.json();

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM