Closed onlyu-bot closed 2 years ago
Finally, I get the refresh_token, by revoking from google account(aka remove the apps access through account).
Everything goes normal again, and I don't need to solve the problem as the title 'Is there other way than header to send request to Google authorization Url to get the code?'.
For more detail please go to stackoverflow
But why I success this time? Because this time I use curl
but not thephpleague/oauth2-client
way to request auth. I think there must missing some parms when I request auth via thephpleague/oauth2-client
.I'll open another issue to discuss this.
I've successfully set up
get_token.php
to get Google OAuth2 for my website(example.com) for PHPMailer, and I can get access token via browser(by select my google account to log in to access).Because I have exceed the limit of refresh token via development, even I've tried to use another google account to create api for my website(example.com), revoke from google account, or delete OAuth and create another one to generate a new clientId; but none of them work, and I think that I will never get a refresh token again.
My website is still running and keeping sending emails, so every hour I have to manually access the access token by link to https://example.com/get_token.php through the browser, so the PHPMailer can use the access token to work.
The document sample use
header
to redirect to the authorization Url, so I have to use browser to execute the code.But I already click to permit to allow access the google api, so I don't need to redirect to the page again. Is there another way to do it? So that I can execute the code via command line, ex:
curl https://example.com/get_token.php
and make the cronJob do it every hour? Thank you!Here is my
get_token.php
Here is my Mail.php