Search code examples
aws-sdkamazon-cognitoaws-sdk-go

How to get a token for aws-sdk-go/service/cognitoidentity


I'm trying to use the go sdk to access coginto, and i'm not sure how to get a token, i'm creating my cogintoidentity with:

creds := credentials.NewStaticCredentials("-id-", "-secret-", "")
sess := session.Must(session.NewSession())
sess.Config.Credentials = creds
sess.Config.Region = aws.String("us-east-1")
sess.Config.CredentialsChainVerboseErrors = aws.Bool(true)
svc := CP.New(sess) // CP == "github.com/aws/aws-sdk-go/service/cognitoidentityprovider"

log.Println(svc.ListUserPools(&CP.ListUserPoolsInput{MaxResults: aws.Int64(10)}))

But it returns The security token included in the request is invalid.


Solution

  • I was using the pool's client id/secret, not my AWS's.