Google Cloud Messaging, 401 Unauthorized is returned when creating notification key from client

我是研究僧i 提交于 2019-12-19 03:21:44

问题


I followed the example on https://developer.android.com/google/gcm/notifications.html#gen-client trying to create notification key from client.

getAccounts() method did return a valid google account. GoogleAuthUtil.getToken(context, accountname, scope) also returns a valid scope string. However the response from the post on https://android.googleapis.com/gcm/googlenotification is 401, and is an html page:

<HTML>
    <HEAD>
        <TITLE>Unauthorized</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
        <H1>Unauthorized</H1>
        <H2>Error 401</H2>
    </BODY>
</HTML>

Logcat shows this: 10-14 13:26:03.911: W/DefaultRequestDirector(22125): Authentication error: Unable to respond to any of these challenges: {}

I double checked the ip filtering, it does show:IPS Any IP allowed.

Wondering whether this is a known issue or anybody has any idea?

FYI I was able to get the id_token by GoogleAuthUtil.getToken. this is the http post format I followed: Http post body: { "operation": "add", "notification_key_name": "appUser-Chris", "registration_ids": ["4"] "id_token": "id_token" } headers: content-type: "application/json" Header : "project_id": Thanks!

来源:https://stackoverflow.com/questions/26242452/google-cloud-messaging-401-unauthorized-is-returned-when-creating-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!