Firebase Cloud Messaging HTTP V1 API:如何通过REST调用获取Auth 2.0访问令牌?

rds

为了将HTTP V1 APIPHP(不是旧版API)与PHP结合使用,必须使用REST接口。

https://firebase.google.com/docs/cloud-messaging/send-message#top_of_page

我想知道如何获取Auth 2.0访问令牌?

https://firebase.google.com/docs/cloud-messaging/auth-server

由于没有Google API Client LibraryPHP(请参见上面的链接中的示例),如何通过REST调用接收Auth 2.0令牌(无需显示PHP代码)?

相关问题:收到此短暂令牌后,如何刷新此令牌?什么是工作流程?

非常感谢!

热罗梅加兹

实际上,有一种适用于PHP的“ Google Api客户端库”,甚至其中两个:

https://github.com/google/google-api-php-client

https://github.com/GoogleCloudPlatform/google-cloud-php

一个提供对API的访问,而另一个则不提供,因此值得一看的是,哪个提供了-您可能需要同时使用它们。

https://github.com/google/google-api-php-client存储库的自述文件中,您可以找到有关如何获取OAuth访问和刷新令牌的说明。

这两个库都在下面与Guzzle一起使用,并提供了一种使用授权中间件来装饰自己的Guzzle HTTP客户端的方法,因此您不必这样做。

因此,如果其中一个库不提供您要访问的API的支持,则可以应用以下代码段中的代码并亲自访问有问题的API(通过Google Api PHP客户端-“直接进行HTTP请求”) :

// create the Google client
$client = new Google_Client();

/**
 * Set your method for authentication. Depending on the API, This could be
 * directly with an access token, API key, or (recommended) using
 * Application Default Credentials.
 */
$client->useApplicationDefaultCredentials();

// returns a Guzzle HTTP Client
$httpClient = $client->authorize();

无耻的插件:我正在https://github.com/kreait/firebase-php维护一个单独的Admin SDK,以访问与Firebase相关的API ,它具有FCM组件,该组件在此处记录:https:// firebase-php。阅读thedocs.io/en/stable/cloud-messaging.html

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在哪里可以找到Firebase Cloud Messaging的API KEY?

Firebase Cloud Messaging免费吗?

Firebase Cloud Messaging-管理注册令牌

FCM HTTP V1 API返回404,以获取未注册的令牌

使用新的HTTP v1 API时,Firebase Data消息未传递到iOS

Google Cloud Logging:是否使用V2 API搜索v1条目?

Google Cloud Messaging vs Firebase

Google Cloud Messaging与Firebase

Firebase Cloud Messaging Auth令牌与注册令牌

Firebase Cloud Messaging Statistics API

Firebase Cloud Messaging的不同密钥

如何在Angular2中实例化Firebase Cloud Messaging

我怎么知道Firebase Cloud Messaging令牌已停用?

如何在不请求通知许可的情况下获取Firebase Cloud Messaging的注册令牌?

Firebase Cloud Messaging如何退订主题

使用“新的” Firebase Cloud Messaging API获得403响应

如何获取Firebase Cloud Messaging的OAuth2.0令牌

Firebase Cloud Messaging(FCM)-HTTP V1 API或旧版HTTP API?

Firebase Cloud Messaging-如何向APN添加声音

Firebase Cloud Messaging:为什么要删除注册令牌?

用于Web的Firebase Cloud Messaging:如何发送到多个令牌?

Firebase Cloud Messaging-调用firebase.messaging()时出错

使用Ionic Native Push获取Firebase Cloud Messaging的正确FCM注册令牌

是否可以每次断开与Firebase Cloud Messaging(FCM)的HTTP连接?

用户注销React Native应用程序时如何删除Firebase Cloud Messaging令牌?

Firebase Cloud Messaging删除通知

Firebase Cloud Messaging onMessageSent未调用

Firebase Cloud Messaging使用Java发送HTTP发布

Firebase Cloud Message 通过 HTTP v1 api 使用主题函数返回 400