1. <small id='u8ydU'></small><noframes id='u8ydU'>

      • <bdo id='u8ydU'></bdo><ul id='u8ydU'></ul>
      <legend id='u8ydU'><style id='u8ydU'><dir id='u8ydU'><q id='u8ydU'></q></dir></style></legend>
      <i id='u8ydU'><tr id='u8ydU'><dt id='u8ydU'><q id='u8ydU'><span id='u8ydU'><b id='u8ydU'><form id='u8ydU'><ins id='u8ydU'></ins><ul id='u8ydU'></ul><sub id='u8ydU'></sub></form><legend id='u8ydU'></legend><bdo id='u8ydU'><pre id='u8ydU'><center id='u8ydU'></center></pre></bdo></b><th id='u8ydU'></th></span></q></dt></tr></i><div id='u8ydU'><tfoot id='u8ydU'></tfoot><dl id='u8ydU'><fieldset id='u8ydU'></fieldset></dl></div>

    2. <tfoot id='u8ydU'></tfoot>

      使用“new"获取 403 响应.Firebase 云消息传递 API

      Get 403 response with the quot;newquot; Firebase Cloud Messaging API(使用“new获取 403 响应.Firebase 云消息传递 API)
    3. <tfoot id='VbkSm'></tfoot>

      <small id='VbkSm'></small><noframes id='VbkSm'>

          <tbody id='VbkSm'></tbody>
        • <bdo id='VbkSm'></bdo><ul id='VbkSm'></ul>
          1. <i id='VbkSm'><tr id='VbkSm'><dt id='VbkSm'><q id='VbkSm'><span id='VbkSm'><b id='VbkSm'><form id='VbkSm'><ins id='VbkSm'></ins><ul id='VbkSm'></ul><sub id='VbkSm'></sub></form><legend id='VbkSm'></legend><bdo id='VbkSm'><pre id='VbkSm'><center id='VbkSm'></center></pre></bdo></b><th id='VbkSm'></th></span></q></dt></tr></i><div id='VbkSm'><tfoot id='VbkSm'></tfoot><dl id='VbkSm'><fieldset id='VbkSm'></fieldset></dl></div>
          2. <legend id='VbkSm'><style id='VbkSm'><dir id='VbkSm'><q id='VbkSm'></q></dir></style></legend>

                本文介绍了使用“new"获取 403 响应.Firebase 云消息传递 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我们已成功使用 旧版 HTTP 服务器协议我们的 FCM 服务器.我今天想更新到 FCM HTTP v1 API.

                We are successfully using the Legacy HTTP Server Protocol on our server for FCM. I wanted to update to FCM HTTP v1 API today.

                我做到了一步一步,当服务器调用请求,我们得到这个响应:

                I did it step by step and when the server calls the request, we get this response:

                Server returned HTTP response code: 403 for URL: https://fcm.googleapis.com/v1/projects/[projectid]/messages:send
                

                这是服务器代码:

                URL url = new URL("https://fcm.googleapis.com/v1/projects/[projectid]/messages:send");
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestProperty("Authorization", "Bearer " + getAccessToken());
                conn.setRequestProperty("Content-Type", "application/json");
                OutputStream outputStream = conn.getOutputStream();
                outputStream.write(req.getBytes("UTF-8"));
                
                // Exception happen here
                InputStream inputStream = conn.getInputStream();
                

                getAccessToken():

                The getAccessToken():

                private static String getAccessToken() throws IOException {
                        GoogleCredential googleCredential = GoogleCredential
                            .fromStream(new FileInputStream(ClientApiServlet.context.getRealPath("/WEB-INF/[projectid].json")))         .createScoped(Arrays.asList("https://www.googleapis.com/auth/firebase.messaging"));
                        googleCredential.refreshToken();
                        return googleCredential.getAccessToken();
                }
                

                我已经从 firebase 云的 adminsdk 页面下载了 json 文件.

                I have downloaded the json file from the adminsdk page of the firebase cloud.

                都具有相同的投影...

                All with the same projectid...

                我在服务器上更新了这两个库:

                I updated these 2 libs on the server:

                google-http-client-jackson2-1.23.0.jar
                google-oauth-client-1.23.0.jar
                

                getAccessToken() 方法返回一个访问令牌:ya29.c.Elr0BAa..."

                The getAccessToken() methode returned an accesstoken: "ya29.c.Elr0BAa..."

                我想,我错过了一小步,也许你能帮忙?提前致谢!

                I think, I miss a small step, maybe you could help? Thanks in advance!

                它现在在 arterpa 的提示下工作!再次感谢!

                It is working now with the hint of arterpa! Thanks again!

                之后我得到一个 400 错误,所以请求数据中有错误:

                After that I got a 400 error, so something in the request data was wrong:

                问题是,我们没有将所有 data{...} 值转换为字符串.对于遗留协议,这不是问题,但对于 FCM HTTP v1 API,它必须是字符串!;)

                The problem was, we didn't converted all data{...}values to strings. With the legacy protocol it was not an issue, but with FCM HTTP v1 API it has to be strings! ;)

                推荐答案

                我遇到了这个问题,您似乎需要在 Google API 控制台.

                I had this problem, and it seems you need to enable FCM API for your project at Google API console.

                这篇关于使用“new"获取 403 响应.Firebase 云消息传递 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                Android file copy(安卓文件拷贝)
                Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)
                    <bdo id='Oc1o7'></bdo><ul id='Oc1o7'></ul>

                      <i id='Oc1o7'><tr id='Oc1o7'><dt id='Oc1o7'><q id='Oc1o7'><span id='Oc1o7'><b id='Oc1o7'><form id='Oc1o7'><ins id='Oc1o7'></ins><ul id='Oc1o7'></ul><sub id='Oc1o7'></sub></form><legend id='Oc1o7'></legend><bdo id='Oc1o7'><pre id='Oc1o7'><center id='Oc1o7'></center></pre></bdo></b><th id='Oc1o7'></th></span></q></dt></tr></i><div id='Oc1o7'><tfoot id='Oc1o7'></tfoot><dl id='Oc1o7'><fieldset id='Oc1o7'></fieldset></dl></div>

                          <tbody id='Oc1o7'></tbody>

                        <small id='Oc1o7'></small><noframes id='Oc1o7'>

                        <legend id='Oc1o7'><style id='Oc1o7'><dir id='Oc1o7'><q id='Oc1o7'></q></dir></style></legend>
                        <tfoot id='Oc1o7'></tfoot>