-
Notifications
You must be signed in to change notification settings - Fork 168
Token expired? #290
Comments
I think you had an expired authorisation token., Re-creating the client secret would not help with this. But running with --new-token would fix it right away (A full re-install would also have the side effect of deleting the expired token too). I need to highlight this in the expired token error message., |
Yes -- sorry -- I'm all good now. |
I had the same issue. Running Is there a way to either (a) request a non-expiring token / set the token expiry to some absurdly large value, (b) use a different auth method that never expires, or (c) automatically refresh the token? I'm definitely no guru at OAuth, but it seems like |
I don't know what is happening here since my tokens have all lasted for a few years now. It's possible that your token is not set up to have a refresh token it maybe Google have introduced new token policies If you would like me to investigate this please recreate your secret and post the screens you go through to do so. |
Re Refresh tokens. Yes that is what we use and it usually works. I'm wondering if in setting up your secret you have somehow specified that refresh is not allowed. |
I kinda figured that I may have set up the OAuth token incorrectly. These are my notes on what I did to create the OAuth 2.0 client ID. (Basically, I followed https://www.linuxuprising.com/2019/06/how-to-backup-google-photos-to-your.html) Create Google Cloud project:
Enable the Photos API for the project:
Create the Credentials:
That's basically what I did. I went through those actions again and tried to look for any settings on the OAuth Client ID, but didn't see anything that might set the expiry. |
still happening weekly for me as well |
Sorry, I can't see anything wrong with the steps posted by Douglas.
Google is not giving much love to the issues with the Photos API, maybe
they are crippling the credentials renewal too :-(
…On Fri, 14 May 2021 at 15:23, Shell M. Shrader ***@***.***> wrote:
still happening weekly for me as well
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#290 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHLRW3E6KAQCGTO6LORITTTNUW5PANCNFSM4W32CEBQ>
.
|
TL;DR:Publish the Google App. From https://developers.google.com/identity/protocols/oauth2#expiration (emphasis mine):
To publish the app, here's what I did:
I'll try to report back here after 7 days and see if things are actually fixed. I'm betting they are. Other notes that might be of interestThe $ grep -r "InvalidGrantError"
gphotos210514_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210515_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210516_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210517_230004.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210518_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210519_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210520_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210521_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210522_230007.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Bad Request |
Thanks Douglas, this does look promising.
…On Mon, 24 May 2021 at 00:57, Douglas Thor ***@***.***> wrote:
TL;DR:
*Publish the Google App.*
From https://developers.google.com/identity/protocols/oauth2#expiration
(emphasis mine):
A Google Cloud Platform project with an OAuth consent screen configured
for an external user type and a publishing status of "Testing" is issued a
refresh token expiring in *7 days*.
To publish the app, here's what I did:
1. Head to the project's *APIs & Services* dashboard in GCP.
2. Click on *OAuth consent screen*
3. Press *Publish App*
4. Confirm the notice about pushing to production
5. Re-run gphotos-sync with the --new-token arg.
6. Head to the link the gphotos-sync provides.
7. You'll get a warning about unverified apps. Press *Advanced* and
then *Go to AppName (Unsafe)*.
[image: image]
<https://user-images.githubusercontent.com/5386897/119280541-bfd1c500-bbe6-11eb-95fb-100cc54e15ab.png>
8. Follow the rest of the steps as normal.
I'll try to report back here after 7 days and see if things are actually
fixed. I'm betting they are.
Other notes that might be of interest
The oauthlib.oauth2.rfc6749.errors.InvalidGrantError message changes from
"Token has been expired or revoked." to "Bad Request" 7 days after the
expiry (this could cause some annoyances when investigating things):
$ grep -r "InvalidGrantError"
gphotos210514_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210515_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210516_230005.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210517_230004.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210518_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210519_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210520_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210521_230003.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Token has been expired or revoked.
gphotos210522_230007.log:oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Bad Request
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#290 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHLRW2XG4GXRZJ6NBFCKV3TPGJABANCNFSM4W32CEBQ>
.
|
Well it's been over a week since I published the google app and things are still working wonderfully. I'm inclined to say this is resolved. |
Thanks @dougthor42 that's great. I guess this requirement is not backdated since my 3 year old token still works. Would you be interested in making a PR that adds your steps for creating the token.? Maybe we should start a separate MD file linked from readme.md |
I had to re-install gphotos from scratch. I generated a new oauth key using the guide.....but still seem to be getting the error below at start up?
01-31 18:13:13 WARNING gphotos-sync 2.14.0+4.37fad11 2021-01-31 18:13:13.472700
01-31 18:13:13 ERROR
Process failed.
Traceback (most recent call last):
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
url, http_method=method, body=data, headers=headers
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/gphotos/Main.py", line 417, in main
self.setup(args, db_path)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/gphotos/Main.py", line 309, in setup
self.google_photos_client = RestClient(photos_api_url, self.auth.session)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/gphotos/restclient.py", line 38, in init
service_document = self.auth_session.get(api_url).json()
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 497, in request
self.auto_refresh_url, auth=auth, **kwargs
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 446, in refresh_token
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
validate_token_parameters(params)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 438, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/home/will/.local/share/virtualenvs/will-PWwV11kO/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Bad Request
01-31 18:13:13 WARNING Done.
The text was updated successfully, but these errors were encountered: