KaMM
KaMM

Reputation: 51

Google Photos API - authentication

I'm trying to get list of my shared albums from Google Photos. I found a enable Photos API in Google Developers Console.

HTTP GET: https://content-photoslibrary.googleapis.com/v1/sharedAlbums?key=AIzaSyCkXXXXXXXXXXXXXZiOSe9IiyM8E

RESULT:

{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } } 1

Configuration in developers console:

Please, what I'm doing wrong? Thank you.

Upvotes: 3

Views: 8335

Answers (3)

Giles Knap
Giles Knap

Reputation: 535

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).

Upvotes: 0

StefansArya
StefansArya

Reputation: 2888

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.

Upvotes: 2

Jan-Felix Schmakeit
Jan-Felix Schmakeit

Reputation: 1106

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

Upvotes: 1

Related Questions