Google Photos API - authentication

老子叫甜甜 提交于 2019-12-04 22:06:04

You need to configure OAUth 2.0 credentials (client ID and secret) and not an API key. More details are in the developer documentation here: https://developers.google.com/photos/library/guides/get-started#request-id

The Google Photos library API acts on behalf of a user, that's why you need to authenticate via OAuth 2.0. As part of this request you also need to specify a scope for your users to accept, see this page for more details: https://developers.google.com/photos/library/guides/authentication-authorization

Google API need an access token to make sure that the user has the permission to access the feature. Access token is just like cookie that should be send together with the request.

Usually you will need so many setup to get the access token with your own code. But there are a client library that can help you access Google API with small setup.

Access token also has a lifetime, so if you don't use the library you will need to manually refresh the token.

I've been working on a python project to backup google photos library and album info. you can probably modify it to do exactly what you want. It is fully working but does not currently distinguish between shared and private albums.

https://github.com/gilesknap/gphotos-sync

In particular, see https://github.com/gilesknap/gphotos-sync/blob/master/gphotos/authorize.py which handles authentication and authorization for any Google service (it also handles storing the token and refreshing the token).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!