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 issue #73

Open
dkoudrinhc opened this issue Dec 1, 2021 · 19 comments
Open

invalid_grant issue #73

dkoudrinhc opened this issue Dec 1, 2021 · 19 comments

Comments

@dkoudrinhc
Copy link

Hi,

I've had the gmail-tester plugin work for a couple of days after setting it up, but then every few days it breaks with this error:

CypressError: cy.task('gmail:check') failed with the following error:

invalid_grant
https://on.cypress.io/api/task

Anyone have any idea what could be going wrong here? I really need this to work consistently.

@levz0r
Copy link
Owner

levz0r commented Dec 3, 2021

Hello,
Have you tried invoking refresh_access_token()?

@dkoudrinhc
Copy link
Author

Hello, Have you tried invoking refresh_access_token()?

Not sure what that means sorry, is it mentioned anywhere in the documentation?

@levz0r
Copy link
Owner

levz0r commented Dec 4, 2021

@dkoudrinhc
Copy link
Author

Yes. Please try this: https://github.com/levz0r/gmail-tester#refresh_access_tokencredentials_json-token_path

Still not sure how to use it. All it says in that readme is this:
refresh_access_token(credentials_json, token_path)
credentials_json: Path to credentials JSON file.
token_path: Path to existing OAuth2 token file.
Refresh the access token. A new file will overwrite the existing one in token_path.

From that I don't understand how to actually refresh a token, there's no code example, or anything.

@MAfzalKhan1997
Copy link

Yes. Please try this: https://github.com/levz0r/gmail-tester#refresh_access_tokencredentials_json-token_path

Still not sure how to use it. All it says in that readme is this: refresh_access_token(credentials_json, token_path) credentials_json: Path to credentials JSON file. token_path: Path to existing OAuth2 token file. Refresh the access token. A new file will overwrite the existing one in token_path.

From that I don't understand how to actually refresh a token, there's no code example, or anything.

following

@jbird21
Copy link

jbird21 commented Dec 30, 2021

same issue now also. I have built in the refresh token as a task:

on("task", { "gmail:refreshAccessToken": async args => { await gmail_tester.refresh_access_token( path.resolve("./cypress/support/gmail/", "client.json"), path.resolve("./cypress/support/gmail/", "token.json"), ); }, });

but it doesn't get a new token / generate a new file.

@Gamerdachs
Copy link

Same issue, I setup the credentials, and after about a week or so I get the message "invalid_grant", even though the expiration date is far away in the future.

@jbird21
Copy link

jbird21 commented Jan 19, 2022

TO fix this i had to:

  • Delete existing Token
  • Run ./node setup (as per guide again) and then verify via Google. I wonder if it is something to do with Google more than the code itself ?

@dkoudrinhc
Copy link
Author

TO fix this i had to:

  • Delete existing Token
  • Run ./node setup (as per guide again) and then verify via Google. I wonder if it is something to do with Google more than the code itself ?

That doesn't really fix the problem, in 7 days you will get invalid_grant again. Still hoping someone is able to come up with a permanent solution.

@Gamerdachs
Copy link

It would be a great solution to authenticate via Google Service Account @levz0r

@tgecb
Copy link

tgecb commented Oct 11, 2022

Hey, has anyone found a solution for that? Would the current implementation be able to use a Google Service Account?

@jbird21
Copy link

jbird21 commented Oct 11, 2022

NOPE

@LukasLewandowski
Copy link

+1

@TomaszCichon
Copy link

It looks like its working fine, on cypress.config.js I have:
on("task", {
"gmail:refreshAccessToken": async args => {
const token = await gmail_tester.refresh_access_token('./cypress/plugins/credentials.json', './cypress/plugins/token.json')
return config
}
})

on test:
cy.task("gmail:refreshAccessToken")

and expirydate (...."expiry_date":1665564390017}) is refreshed every time the task is launched.

@tgecb
Copy link

tgecb commented Oct 12, 2022

It looks like its working fine

It works fine for a week, then the token can't be refreshed anymore, returning this invalid_grant error

To elaborate on this, we can't refresh the token after a week because the OAuth consent screen managed in the Google cloud console is in testing mode. If we switch it to production mode, then the token could be refreshed indefinitely, but then the problem is that we can't use the authorization url generated by the init.js script in production mode anymore since october 3rd:
https://developers.google.com/identity/protocols/oauth2/resources/oob-migration

@LukasLewandowski
Copy link

Any progress? Can we expect some solution to that problem? :)

@dorisLi2014
Copy link

Any updates here? If the token can not be refreshed programatically, the use of the module is very limited.

@LukasLewandowski
Copy link

It is big limitation in did, it forced me to switch to mail.tm

@taninnazar
Copy link

@levz0r any help from your side to resolve this?

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

10 participants