I have implemented tripartite OAuth using the Google OAuth API in Java.
My application is registered with GAE. And I also successfully get an access token. But now, when I create a UserService object, even if I am registered in Gmail, as well as in my personal mail, it returns null when calling getCurrentUser ()!
My code is:
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
oauthParameters.setScope("https://spreadsheets.google.com/feeds/");
oauthParameters.setOAuthType(OAuthParameters.OAuthType.THREE_LEGGED_OAUTH);
oauthParameters.setOAuthToken(request.getSession().getAttribute("oauth_token").toString());
oauthParameters.setOAuthTokenSecret(request.getSession().getAttribute("oauth_token_secret").toString());
UserService userService = UserServiceFactory.getUserService();
out.println("<br/>Get Current User : " + userService.getCurrentUser());
There is no need to specifically add a jar when using User Service. Then what is the problem?
Also, when I try to do this:
out.println(userService.isUserLoggedIn() ? "User is Logged In" : "User is Log Off");
It outputs:
User is disconnected
while I enter my personal domain and gmail like! I think this should probably redirect me to the login page in case I sign up. But this is not so!
, systempuntout , :
OAuthService oauth = OAuthServiceFactory.getOAuthService();
User user = oauth.getCurrentUser();
out.println("<br/>Get Current User : " + user.getNickname());
, !: (
Google App Engine :
Oauth.requestServlet doGet: null
com.google.appengine.api.oauth.InvalidOAuthParametersException: Unknown
at com.google.appengine.api.oauth.OAuthServiceImpl.makeSyncCall(OAuthServiceImpl.java:73)
at com.google.appengine.api.oauth.OAuthServiceImpl.getGetOAuthUserResponse(OAuthServiceImpl.java:53)
at com.google.appengine.api.oauth.OAuthServiceImpl.getCurrentUser(OAuthServiceImpl.java:28)
at Oauth.accessFeeds.access(accessFeeds.java:60)
at Oauth.requestServlet.processRequest(requestServlet.java:129)
at Oauth.requestServlet.doGet(requestServlet.java:199)
: API: com.google.appengine.api.oauth, com.google.appengine.api.users
( ) Google OAuth?
user284291