'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?
Solution 1:[1]
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();
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Carlos Alatorre |
