Google Photos API-身份验证 [英] Google Photos API - authentication

查看:110
本文介绍了Google Photos API-身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Google相册获取我的共享相册的列表. 我在Google Developers Console中找到了一个启用的Photos API.

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

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

结果:

{ "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.

推荐答案

Google API需要访问令牌,以确保用户有权访问该功能.访问令牌就像应该与请求一起发送的cookie.

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.

通常,您需要进行大量设置才能使用您自己的代码获取访问令牌.但是,有一个客户端库可以帮助您以较小的设置访问Google API.

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.

这篇关于Google Photos API-身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆