gmail-tester
gmail-tester copied to clipboard
invalid_grant issue
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.
Hello,
Have you tried invoking refresh_access_token()?
Hello, Have you tried invoking
refresh_access_token()?
Not sure what that means sorry, is it mentioned anywhere in the documentation?
Yes. Please try this: https://github.com/levz0r/gmail-tester#refresh_access_tokencredentials_json-token_path
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.
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
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.
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.
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 ?
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.
It would be a great solution to authenticate via Google Service Account @levz0r
Hey, has anyone found a solution for that? Would the current implementation be able to use a Google Service Account?
NOPE
+1
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.
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
Any progress? Can we expect some solution to that problem? :)
Any updates here? If the token can not be refreshed programatically, the use of the module is very limited.
It is big limitation in did, it forced me to switch to mail.tm
@levz0r any help from your side to resolve this?