Getting Oauth token in app engine endpoints -
i looking way of obtaining oauth2 token app engine java endpoint.
i aware of doing this, example:
@apimethod(name = "getmyresponse", path = "getmyresponse", httpmethod = apimethod.httpmethod.get) public myresponse getmyresponse(final user user, httpservletrequest request) throws userunauthorizedexception { string authorizationheader = request.getheader("authorization"); string token = authorizationheader.substring(7); //do token here }
however, looking bit more "civilized", parsing strings http header (like using api, example). ideas?
if need token, seems uncivilized, i'd suggest writing yourself. api possibly use add weight codebase. write helper function :
private static string gettoken (httpservletrequest req){ string authorizationheader = req.getheader("authorization"); string token = authorizationheader.substring(7); return token; }
and in code reference
string token = gettoken(request);
and code civilized.
Comments
Post a Comment