[英]How can i get a Oauth 2.0 access token for firebase in my Spring app
I am trying to retrieve an Oauth 2.0 access token in my Spring boot application so i can send push notification via my server. 我试图在我的Spring启动应用程序中检索Oauth 2.0访问令牌,以便我可以通过服务器发送推送通知。 I followed firebase documentation but they failed to show an example of how to retrieve the token with the google client library they stated and also how to link the private key json file with it.
我遵循了Firebase文档,但他们未能显示一个示例,说明如何使用他们声明的Google客户端库检索令牌以及如何将私钥json文件与其链接。 Presently i have downloaded and saved the private key file on my system and also imported the Google API Client Library via maven.
目前,我已经在系统上下载并保存了私钥文件,还通过maven导入了Google API客户端库。 But i am stuck on how to actually use them to get a token.
但是我对如何实际使用它们来获取令牌感到困惑。
Please an assistance here in terms of a code snippet will be helpful. 请在代码段方面为您提供帮助。
You can use the OAuthRestTemplate, you just configure it as a bean and it will automatically get tokens as needed. 您可以使用OAuthRestTemplate,只需将其配置为Bean,它将根据需要自动获取令牌。
Here is one page with examples, but there are tons online depending on what type of token you are using. 这是一个包含示例的页面,但在线数量取决于您使用的令牌类型。 OAuthRestTemplate Examples
OAuthRestTemplate示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.