Google Cloud Messaging, returning 401 Unauthorized while generating the notifkey on the client side

28 views
Skip to first unread message

ISSAM BEN SIRHIR

unread,
Mar 4, 2015, 3:46:30 AM3/4/15
to andro...@googlegroups.com

I followed the example on https://developer.android.com/google/gcm/notifications.html#gen-clienttrying 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 onhttps://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>

By the way here is the request code I used to generate the notification Key on the client Side

request:
{
   "operation": "add",
   "notification_key_name": "appUser-Chris",
   "registration_ids": ["4"]
   "id_token": "id_token"
}

And concerning the Post Request I have used this URL

 https://android.googleapis.com/gcm/googlenotification

Along with this header information

content-type: "application/json"
Header : "project_id": <projectID>

PS : I also tried to include the Authorization Key to generate the notification key but it didn't work .

Note : Keep in mind that I want to generate the Notif Key on the client side not on the server side.

Wondering whether this is a known issue or anybody has any idea? Thanks! And I would really Appreciate your help.

I have searched everywhere , I couldn't get an answer for my problem.

Please help me here I m hopeless.

Reply all
Reply to author
Forward
0 new messages