接到标识和身份验证令牌后,发送邮件时C2DM 401错误 [英] c2dm 401 error when sending messages after receiving id and auth token

查看:198
本文介绍了接到标识和身份验证令牌后,发送邮件时C2DM 401错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多similiar问题,但尽管他们中的一些没有很好的答案被接受。 我已经注册了C2DM。我收到的确认邮件。然后,我写了一些简单的应用程序来注册C2DM。我得到的ID(尝试在模拟器和实际设备)。然后我拿到了身份验证令牌(与卷曲)我的电子邮件,我使用的C2DM注册(我在应用程序中使用,用于获取ID相同的电子邮件)。
当我尝试做推(也有卷曲),我得到401错误(如身份验证令牌是错误的)。

I have seen many similiar questions but no good answer despite some of them being accepted. I have registered for C2DM. I received confirmation email. Then I wrote some simple app to register for C2DM. I get the id (tried on emulator and on real device). Then I got the auth token (with curl) for my email that I used for C2DM registration (the same email that I use in app for acquiring the id).
When I try to do the push (also with curl), I get 401 error (like the auth token is wrong).

我看了很多教程,我运行的想法。

I read many tutorials and I am running out of ideas.

推荐答案

让我试试(与卷曲只):

Let me try it (with curl only):

起初,我们所申请的身份验证令牌:

At first we are applying for the auth token:

curl.exe -v -k https://www.google.com /帐号/ ClientLogin的 -d Email=xyz@gmail.com -d =的passwd -d秘密= accountType GOOGLE -d源= your.registered.domain -d服务= ac2dm

curl.exe -v -k https://www.google.com/accounts/ClientLogin -d Email=xyz@gmail.com -d Passwd=secret -d accountType=GOOGLE -d source=your.registered.domain -d service=ac2dm

在结果你正在接受身份验证令牌:

In the result your are receiving the auth token:

< HTTP / 1.1 200 OK
SID = XXX
LSID = XXX
验证= XXX
*连接#0到主机www.google.com原封不动
*关闭连接#0
*在SSLv3,TLS警告,客户端问候(1):

< HTTP/1.1 200 OK
SID=XXX
LSID=XXX
Auth=XXX
* Connection #0 to host www.google.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

请注意,验证反应是在结果以大写首字母:验证= XXX

Please note that the Auth response is in the result with an uppercase first letter: "Auth=XXX"!

现在我们使用的结果下一个请求,但与首字母小写:
curl.exe -v -k --header授权:的GoogleLogin的权威性 = XXX的 https://android.apis.google.com/c2dm/send -dregistration_id = XXX-d数据= helloooo-d collapse_key = Z

Now we are using the result for the next request but with lowercase first letter:
curl.exe -v -k --header "Authorization: GoogleLogin auth=XXX" https://android.apis.google.com/c2dm/send -d "registration_id=XXX" -d "data=helloooo" -d collapse_key=Z

和这个作品!但是,你得到一个401错误,如果你在第一个响应使用AUTH类似(在验证大写A):

And this works! But you are getting a 401 error, if you are using the auth like in the first response (upper case A in "Auth"):

curl.exe-v -k --header授权:的GoogleLogin 验证 = XXX的 https://android.apis.google.com/c2dm/send -dregistration_id = XXX-d数据= helloooo-d collapse_key = Z

curl.exe" -v -k --header "Authorization: GoogleLogin Auth=XXX" https://android.apis.google.com/c2dm/send -d "registration_id=XXX" -d "data=helloooo" -d collapse_key=Z

所以请求2的权威性是区分大小写的。我认为这是一个陷阱中50%的用户正在加紧进入。希望有所帮助。

So the "auth" of request 2 is case sensitive. I think this is a pitfall 50% of the users are stepping into. Hope that helps.

这篇关于接到标识和身份验证令牌后,发送邮件时C2DM 401错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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