Вопрос

Using restlet, I want to make a post to android's c2dm service. I have tried this from a generic rest client and all worked ok. However, when I try to post using restlet, I get a (401) - Unauthorized response.

For authorization, I need to set the following header:

Authorization: GoogleLogin auth=my_auth_token

How do I set this header using restlet? I know I need to set a challenge response, but I'm not sure about it's parameters. Is "GoogleLogin " my ChallengeScheme? Do i use it like this:

ChallengeScheme.valueOf("GoogleLogin")

What about setting the token?

Thanks

Это было полезно?

Решение

You can create a custom scheme and set the challenge response with this scheme for your requests :

ChallengeScheme sc = new ChallengeScheme("Google_Login", "GoogleLogin", "Android c2dm service");
clientResource.setChallengeResponse(sc, auth, myauthtoken);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top