第一个cURL请求验证GCM api密钥 [英] First cURL request validating GCM api key

查看:787
本文介绍了第一个cURL请求验证GCM api密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在尝试使用GCM API密钥构建我的第一个Android应用程序,该应用程序将由一个营销软件用于发送推送通知。



希望获得一些用卷曲请求帮助验证我的Google云消息(GCM)API密钥。我尝试过使用在线卷发生成器,但结果不匹配我期望的成功或错误消息。



下面的请求已经从push sdk文档中复制过来。如果它出现401错误,我需要将我的GCM项目更新为FCM项目。

  curl --header授权:key = AIzaSyBIuNzItgztXS31MYdl0xnszQcAUO7lbOg
--header Content-Type:application / json
https://android.googleapis.com/gcm/send -d{\registration_ids \: [\ABC \]}

我显然很想知道如何做到这一点我也是。



预先感谢。

您可以尝试使用邮递员发送简单的下游邮件。
$ b


  1. 将请求类型设置为 POST 并提供网址。




  2. 设置标题:




    • 授权 = =<服务器密钥> (h在您刚开始时,建议继续使用FCM而不是GCM,因为只能通过创建Firebase项目来生成新的有效服务器密钥。)

    • Content-Type = application / json




  3. 点击发送


您应该收到 InvalidRegistration ,a 401 或者无效的传统服务器密钥... 错误:




  • InvalidRegistration 错误表示令牌无效,但服务器密钥有效。

  • 401 表示无效凭证,对于此特定请求,它是服务器密钥。 传送的无效(遗留)服务器密钥或发件人未被授权执行请求。表示您尝试使用旧格式的服务器密钥(如您的帖子中的密钥)。新服务器密钥的字符更多。通常的回应是这样的:

     < HTML> 
    < HEAD>
    < TITLE>无效(遗留)服务器密钥已交付或发件人未被授权执行请求。< / TITLE>
    < / HEAD>
    < BODY BGCOLOR =#FFFFFFTEXT =#000000>
    < H1>传送的无效(遗留)服务器密钥或发件人未被授权执行请求。< / H1>
    < H2>错误401< / H2>
    < / BODY>
    < / HTML>



  • Currently trying to build my first android app with a GCM API key which will be used by a piece of marketing software to send push notifications.

    Wanted to get some help validating my google cloud message (GCM) API key with a curl request. I've tried using a online curl builder but the results dont match the success or error message im expecting.

    The below request has been copied from the push sdk documentation. If it comes back with a 401 error i need to update my GCM project to a FCM project.

    curl --header "Authorization: key=AIzaSyBIuNzItgztXS31MYdl0xnszQcAUO7lbOg"
    --header Content-Type:"application/json"
    https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
    

    I would obviously love to know how to do this myself also.

    Thanks in advance.

    解决方案

    As per my comment, you could try sending a simple downstream message using Postman.

    1. Set request type to POST and provide the URL.

    2. Set the headers:

      • Authorization = =<Server Key> (here, when you're just starting, it is suggested to proceed with using FCM instead of GCM, since a new valid Server Key can only be generated by creating a Firebase Project).
      • Content-Type = application/json

    3. Set the (JSON payload) body (as raw):

      {
          "registration_ids" : ["ABC"]
      }
      

    4. Click on Send .

    You should receive an InvalidRegistration, a 401, or an Invalid Legacy Server Key... error:

    • InvalidRegistration error means the token(s) are invalid, but the Server Key is valid.
    • 401 means invalid credentials, for this particular request, it's the Server Key.
    • Invalid (legacy) Server-key delivered or Sender is not authorized to perform request. means you attempted to use an old format Server Key (like the one in your post). New Server Key's have more characters. Usual response is like this:

      <HTML>
      <HEAD>
          <TITLE>Invalid (legacy) Server-key delivered or Sender is not authorized to perform request.</TITLE>
      </HEAD>
      <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
          <H1>Invalid (legacy) Server-key delivered or Sender is not authorized to perform request.</H1>
          <H2>Error 401</H2>
      </BODY>
      </HTML>
      

    这篇关于第一个cURL请求验证GCM api密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆