Aws Cognito federated identities answers with UnknownError Not Found on getOpenIdTokenForDeveloperIdentity()

429 views Asked by At

I have an issue in aws lambda (environment nodejs6.10), trying to register a user as custom provider. I'm calling getOpenIdTokenForDeveloperIdentity in my backend, with this params:

const params = {
  IdentityPoolId: config.IDENTITY_POOL_ID,
  Logins: {
    [config.DEVELOPER_PROVIDER_NAME]: id
  }
}

The code responsible for the call is simple:

const cognitoidentity = new AWS.CognitoIdentity({apiVersion: '2014-06-30'})
return cognitoidentity.getOpenIdTokenForDeveloperIdentity(params).promise()
.then(...)

Unfortunately the answer from Cognito is this error:

{
  "message": "Not Found",
  "code": "UnknownError",
  "statusCode": 404,
  "time": "2017-09-13T16:50:12.832Z",
  "requestId": "4RQE2T66K7LOT3RBGOMN0JO82NVV4KQNSO5AEMVJF66Q9ASUAAJG",
  "retryable": false,
  "retryDelay": 58.96973108302359
}

I've done this with almost same code 2 years ago and is still working, but in this project it is not. I've made a little web client for unauthenticated user and it is working well with Cognito, so I assume cognito is set correctly. The region are the same for cognito and lambda, us-east-1. The role and policies seems correct, lambda have permission to do all the stuff with Cognito Identity. I don't know what to do now, just thinking to leave cognito if this cannot be solved. Please help.

Other relevant parts of information: I'm using Serverless framework, but cognito identity pool was created manually (the same for roles).

Lambda allowed permissions:

[
  "cognito-identity:DeleteIdentities",
  "cognito-identity:DescribeIdentity",
  "cognito-identity:GetOpenIdTokenForDeveloperIdentity",
  "cognito-identity:ListIdentities",
  "cognito-identity:LookupDeveloperIdentity",
  "cognito-identity:MergeDeveloperIdentities",
  "cognito-identity:UnlinkDeveloperIdentity"
]

Code initializations

const AWS = require('aws-sdk')

AWS.config.update({
  region: config.REGION
})
AWS.config.setPromisesDependency(require('bluebird'))
1

There are 1 answers

0
napcoder On

Solved: the problem was due to a wrong endpoint in the AWS config, loaded by my dynamodb data layer