Cognito refresh token won't work.

0

Hello, We're using Amazon Cognito as the authentication system for our desktop java client. The login process is working fine. I was able to get the credential from the access token, and use the credential for services like S3, dynamoDB etc.
Now I noticed that Cognito access token only valid for an hour, and I'm trying to use the refresh token to get new access token, but I can't get it to work. I followed the instruction on https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html about how to use the refresh token.

	
InitiateAuthRequest initiateAuthRequest = new InitiateAuthRequest()
				.withAuthFlow(AuthFlowType.REFRESH_TOKEN_AUTH)
				.withClientId(CLIENTAPP_ID);
initiateAuthRequest.addAuthParametersEntry("REFRESH_TOKEN", refreshToken);

Then passed the request to a cognitoIdentityProvider

InitiateAuthResult initiateAuthResult = cognitoIdentityProvider.initiateAuth(initiateAuthRequest);

But I'm getting a NotAuthorizedException, saying "Invalid Refresh Token.", I'm really confused about this error, because the refresh token is extracted from the same challenge result as the access token, and the access token obviously is working fine. Please help!

com.amazonaws.services.cognitoidp.model.NotAuthorizedException: Invalid Refresh Token. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 94aa060a-78cd-11e9-912f-93b3dfdf29d1)

Edited by: yLi on May 17, 2019 11:48 AM

yLi
질문됨 5년 전897회 조회
2개 답변
0

Did you ever figure this out - the question is marked answered, but I don't see an answer - I'm having the exact same problem - and it's very confusing. I have a test case that grabs the tokens from auth, and then tries refresh, and it immediately fails - it's very frustrating!

답변함 4년 전
0
kodless
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠