从 Google 照片 API 获取自己的数据(身份验证和请求)
Getting own data off Google Photos API (Authentication and requests)
我对使用 API 和 React 有点陌生,为了测试它,我正在编写一个项目,其中包括从我拥有的特定专辑中获取我自己的媒体(或只是每个图像的 URL) Google 照片。目的是该项目将 post 我拍摄(并放入此相册)的任何照片放到具有 React 的网站上。
因为我只想要我自己的数据而不想要其他用户的任何 information/authentication 我不能像大多数 google 照片文档所建议的那样只登录(它只会得到他们的 information/pictures 而不是我的?)。
我可以通过在配置(客户端 ID/secret)中提供我自己的凭据加上范围然后 运行 a [=26= 来查看 OAuth Playground 的 data/URLs ] 在对话框中请求我需要的特定 body 数据,但我如何才能将其与 React 一起使用,因为我不能在拍摄新照片时一直刷新令牌并手动输入 URL。
Google Photos api only supports oauth2 authentication. Authencation
A number of google apis have this limitation. What you can do is create a server sided script that will allow you to login and authenticate your application. Make sure to request off line access. This will then return to you an refresh token. You will then be able to use your refresh token to request a new access token when ever you need.
Google does not return a refresh token to javascript applications as they are client sided. You will need to use a server sided language for the refresh token logic.
refresh Tokens created on the oauth2 play ground have a life time of about two hours if last i remember. I am not sure if this is also true with tokens created using your own client.
Technically these are just http post calls so you should be able to code this yourself in any language that can handle http post and get. I am not a react developer so cant help you more then that.
我对使用 API 和 React 有点陌生,为了测试它,我正在编写一个项目,其中包括从我拥有的特定专辑中获取我自己的媒体(或只是每个图像的 URL) Google 照片。目的是该项目将 post 我拍摄(并放入此相册)的任何照片放到具有 React 的网站上。
因为我只想要我自己的数据而不想要其他用户的任何 information/authentication 我不能像大多数 google 照片文档所建议的那样只登录(它只会得到他们的 information/pictures 而不是我的?)。
我可以通过在配置(客户端 ID/secret)中提供我自己的凭据加上范围然后 运行 a [=26= 来查看 OAuth Playground 的 data/URLs ] 在对话框中请求我需要的特定 body 数据,但我如何才能将其与 React 一起使用,因为我不能在拍摄新照片时一直刷新令牌并手动输入 URL。
Google Photos api only supports oauth2 authentication. Authencation
A number of google apis have this limitation. What you can do is create a server sided script that will allow you to login and authenticate your application. Make sure to request off line access. This will then return to you an refresh token. You will then be able to use your refresh token to request a new access token when ever you need.
Google does not return a refresh token to javascript applications as they are client sided. You will need to use a server sided language for the refresh token logic.
refresh Tokens created on the oauth2 play ground have a life time of about two hours if last i remember. I am not sure if this is also true with tokens created using your own client.
Technically these are just http post calls so you should be able to code this yourself in any language that can handle http post and get. I am not a react developer so cant help you more then that.