简体   繁体   中英

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.

Configured the aws user pool with facebook ap id.

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.

I am Getting facebook user id from Auth.currentAuthenticateuser/currenSession .

It has the 3 tokens as well id, access, refresh. but need fb acc_token to get data from facebook API like user permissions.

any way to get facebook access token after aws cognito user pool authentication?

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();

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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