Authorization headers for google login using restlet
-
14-04-2021 - |
Domanda
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
Soluzione
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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow