本文介绍了google-api-php-client:无效的客户端机密JSON文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎PHP的最新版本google-api-php-client与docs @ https://developers.google.com/drive/web/examples/php

Seems that the latest version of the google-api-php-client for PHP doesn't line up with the docs @ https://developers.google.com/drive/web/examples/php

在查看src代码时,我看到它正在寻找setAuthConfigFile()方法找不到的下载JSON中的密钥:在下载的JSON中不存在client_secret,已安装,web,redirect_uris(其他?). .仅存在private_key_id,private_key,client_email,client_id和类型.

Looking at the src code I'm seeing that it's looking for keys in the downloaded JSON that the setAuthConfigFile() method can't find: client_secret, installed, web, redirect_uris (others?) are not present in the downloaded JSON. Only private_key_id, private_key, client_email, client_id, and type are present.

代码和文档似乎真的杂乱无章,不同步...对于Google而言,这并不是第一个.最近有人使用该库让OAuth正常工作吗?

The code and docs seem really disorganized and out of sync... wouldn't be the first for Google. Has anyone gotten OAuth working recently using that library?

推荐答案

服务帐户" 网络应用" 之间的区别在于拨打电话到API.创建服务帐户"时,您将获得上述文件,即带有private_keyclient_emailclient_id等的JSON文件.

There is a difference between a "service account" and a "web apllication" to make calls to the API. When you created a "service account" you will get the file described above, a JSON file with private_key, client_email, client_id etc.

创建Web应用程序时,系统会为您提供client_idclient_secretredirect_uri等.

When you create a web application you will be given a client_id, client_secret, redirect_uri etc.

我建议阅读这些页面以选择所需的键和登录名(在两个页面上都找到将其集成到PHP中的示例):

I would suggest reading these pages to choose which key and login you need (on both pages you find examples to integrate it in PHP):

https://developers.google.com/api-客户端库/php/auth/web-app

https://developers.google.com/api-客户端库/php/auth/service-accounts

这篇关于google-api-php-client:无效的客户端机密JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:10
查看更多