Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_grant: The refresh token is invalid or expired. #19

Closed
handoyo opened this issue Mar 5, 2024 · 11 comments
Closed

invalid_grant: The refresh token is invalid or expired. #19

handoyo opened this issue Mar 5, 2024 · 11 comments

Comments

@handoyo
Copy link

handoyo commented Mar 5, 2024

Hi,

I'm using using server flow to get the access token and refresh token,

I saved both access token and refresh token.

When i call the refreshToken method, i get this error: invalid_grant: The refresh token is invalid or expired..

What should i do so the refresh token is not expired or get updated?

Thnkas

@phpfui
Copy link
Owner

phpfui commented Mar 5, 2024

Are you specifying the scopes correctly:

https://developer.constantcontact.com/api_guide/scopes.html

I seem to remember something about grants, but it was a while back. Also I just changed something recently in the auth code. Roll back to the previous version (24.2 I think) and see if that works.

Let me know what you find.

@handoyo
Copy link
Author

handoyo commented Mar 6, 2024

I didn't specify the scopes.

based on your docs, if we didn't specify the scopes, then it will use all scopes right?

@phpfui
Copy link
Owner

phpfui commented Mar 6, 2024 via email

@handoyo
Copy link
Author

handoyo commented Mar 6, 2024

Not yet, I haven't rolled back the version yet.

I will wait for your info regarding the grant. Thank you.

@phpfui
Copy link
Owner

phpfui commented Mar 6, 2024

Yes, confirmed grant types are part of OAuth. Also it looks like the code is no longer working for my website. I need to investigate why, but could be a setting issue on my side.

So please do try a rollback to the previous version and let me know if that works for you. I suspect that is the issue. There will be an update to the library for sure in the next week, but it would help to have your experience on the previous version.

@phpfui
Copy link
Owner

phpfui commented Mar 6, 2024

I was able to retest the older version of the library and the newer version. They both seem to work, but I would do your own testing.

See issue #17 for other ideas on getting and refreshing the tokens. I think the problem may actually be what the error message says, is that the refresh token is invalid. Have you tried to access an API endpoint other than refresh? If that works, your main token is OK and the refresh token should be good.

I am going to add another Constant Contact feature to my website and will update the library if I find any other issues.

@handoyo
Copy link
Author

handoyo commented Mar 6, 2024

I have add a debug code to get the refresh token last error message to see when the token becomes empty, and it appears after around 3 days, the refresh token expired or becomes invalid.

i was using the rotating instead of long live token.

Could that be the cause?

@phpfui
Copy link
Owner

phpfui commented Mar 6, 2024

Yes, that is likely the problem. I am using a long term token I believe. I also refresh it daily. That seems to work. My cron job runs nightly, and refreshes the token every time, so I have not seen this.

@handoyo
Copy link
Author

handoyo commented Mar 6, 2024

i will try the long live refresh token to see if it still return empty token after several days.

i will let you know the result.

@phpfui
Copy link
Owner

phpfui commented Mar 8, 2024

I did a lot of testing on my own site and things seem to be working correctly. I did fix one minor issue with next() if the API returned an error that would cause multiple extra requests.

@phpfui
Copy link
Owner

phpfui commented Mar 14, 2024

I am closing this issue as I think it was a configuration issue. Open another issue if needed.

@phpfui phpfui closed this as completed Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants