问题描述:

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);
相关阅读:
Top