Any clear documentation on how to implement C2DM? And finally error 401 error sending

91 views
Skip to first unread message

Ditat

unread,
Jun 2, 2012, 2:23:16 PM6/2/12
to androi...@googlegroups.com
I'm really frustrated at this point. Not because I don't know what I'm doing but because I can't find any reliable info on what's needed to get this working.
 
Here is rundown on what I did up to this moment:
 
1. Registered on registration page: https://developers.google.com/android/c2dm/signup
I was logged in to my google account when I did that and I used other email attached to this same account(alias on my google apps for business). Registration didn't work for 2 days (I saw posts on this) - but finaly it got through.
2. Implemented C2DM on Android side. This is easiest part. Device get's Registration_id and I don't see why it wouldn't get messages...
3. My server is C#/WCF. I started to implement according to https://developers.google.com/android/c2dm/
4. Documentation stated I need Client Login to login. Login WHERE? With WHAT UN/PW?
5. Links from c2dm page broken. Finally search for Client Login - deprecated. Nice. Should I use OAuth2? How do I know? c2dm documentation silent.
6. Posting on Stack Overflow. Seems like Client Login is the way to go? http://stackoverflow.com/questions/10859246/c2dm-server-should-we-use-oauth-now
7. Recent Google blog makes me think that Client Login is still what's needed for c2dm: http://android-developers.blogspot.com/2012/04/android-c2dm-client-login-key.html
8. Fine. Using Client Login. Getting auth from google API: https://www.google.com/accounts/ClientLogin Using my account to which I was logged in on #1. Works. I get token.
9. Using API to send: https://android.apis.google.com/c2dm/send Good registration Id, Good Auth token from #8 - 401 from Google. Actually, no. First it failed - SSL is bad on this server. Then I killed SSL check in my code and now it's 401
10. How do I suppose to figure out? No contact info on developers site.
11. Emailed Google Play developers support
12. Found this forum - seems to be alive. Posted. Hopefully Google employees monitor it.
 
Really frustrated! Google need to do better job documenting what needs to be done!
 
 
 

Felipe Leme

unread,
Jun 2, 2012, 4:11:09 PM6/2/12
to androi...@googlegroups.com
Hi Ditat,

See inlined commentes below - hope it helps!

-- Felipe


On Sat, Jun 2, 2012 at 11:23 AM, Ditat <c2...@ditat.net> wrote:
Registered on registration page: https://developers.google.com/android/c2dm/signup
I was logged in to my google account when I did that and I used other email attached to this same account(alias on my google apps for business).


The registration page doesn't require a logged in account (I just accessed  it using Incognito Mode on Chrome).

 
Registration didn't work for 2 days (I saw posts on this) - but finaly it got through.

Yes, there was an issue, but it has been fixed, sorry for inconvenience.
 
8. Fine. Using Client Login. Getting auth from google API: https://www.google.com/accounts/ClientLogin Using my account to which I was logged in on #1. Works. I get token.

I think that's your problem, you're using the wrong account. You should get and use a Client Login token for the sender account you entered in the form, more specifically:

 
9. Using API to send: https://android.apis.google.com/c2dm/send Good registration Id, Good Auth token from #8 - 401 from Google. Actually, no. First it failed - SSL is bad on this server. Then I killed SSL check in my code and now it's 401

The SSL certificate is a known issue (see https://groups.google.com/d/topic/android-c2dm/SekCZX12pTA/discussion), but if you got a 401, then your request reached the C2DM server but was rejected as unauthorized. Please try again with the account I mentioned above. 

Ditat

unread,
Jun 2, 2012, 4:17:33 PM6/2/12
to androi...@googlegroups.com
 
What about OAuth? Should it work? Should I go for OAuth2 in C2DM?  
 
 
I didn't want to use my actual account login as sender, so I specified c2...@mydomain.com and added that email as alias on my Google Apps account (paid account)
I guess this is what the problem is. I will try to setup complete standalone account for this specific purpose as I need to store password on server.

Ditat

unread,
Jun 2, 2012, 4:31:04 PM6/2/12
to androi...@googlegroups.com
OK! Success!
 
It works when I created account and used sender email as my main account email.
 
Question remains... Should we bother using OAuth2 and if C2DM even supports it?
 
Also, if we do do use OAuth2, does it mean additional Google API account need to be setup?

Felipe Leme

unread,
Jun 2, 2012, 6:22:50 PM6/2/12
to androi...@googlegroups.com
On Sat, Jun 2, 2012 at 1:31 PM, Ditat <c2...@ditat.net> wrote:
Question remains... Should we bother using OAuth2 and if C2DM even supports it?

Yes, it supports OAuth2.
 
Also, if we do do use OAuth2, does it mean additional Google API account need to be setup?

You won't need any additional setup in the C2DM side, but you will need to use the Google API console to get the OAuth2 tokens.

Ditat

unread,
Jun 2, 2012, 6:47:56 PM6/2/12
to androi...@googlegroups.com
Do I need to setup Service account for this? And when I send message to C2DM what kind of token do I need to send along?
Reply all
Reply to author
Forward
0 new messages