IdentityPoolId: identityPoolId,
Logins: {
"api.twitter.com": combinedToken,
}
}));
if (!getIdResponse.IdentityId) {
throw new Error('No IdentityId returned from GetIdCommand');
}
const credentialsResponse = await cognitoIdClient.send(new GetCredentialsForIdentityCommand({
IdentityId: getIdResponse.IdentityId,
Logins: {
"api.twitter.com": combinedToken,
}
}));
request payload
{
"IdentityPoolId": "eu-central-1:xxxxxxxxxxx",// my identity pool id
"Logins": {
"api.twitter.com": "GFy5FwAAAAABrVmwAAABjElMvO4;E6fn05h8QZkvZcn4WkO3A7qWpBuTgmMc" // i get them from the request everytime
}
}
request response
{"__type":"NotAuthorizedException","message":"Invalid login token."}
in aws i have add the correct keys that i used to generate the tokens in the code
that i get them like this
const requestData = {
url: 'https://api.twitter.com/oauth/request_token',
method: 'POST',
data: { oauth_callback: 'http://localhost:3000/CallbackPage/' }, // Your server-side callback URL
};
const authHeader = oauth.toHeader(oauth.authorize(requestData));
const response = await axios.post(requestData.url, null, { headers: { Authorization: authHeader['Authorization'], 'Content-Type': 'application/x-www-form-urlencoded' } });
const responseParams = new URLSearchParams(response.data);
const requestToken = responseParams.get('oauth_token');
const requestTokenSecret = responseParams.get('oauth_token_secret');
if (!requestToken || !requestTokenSecret) {
throw new Error('Failed to obtain request token or secret');
}
// Send the requestToken and requestTokenSecret to the client
res.status(200).json({ requestToken, requestTokenSecret });
to get the correct response from AWS and check what is wrong in my process
