OAuth in Google Data API using Java

Does anyone know any example web application that used Oauth with the Google Data API?

+3
source share
1 answer

From what I understand (correct me if I am wrong). To return the request token, set oauth_callbackto the absolute path where it oauth_tokenwill be added to oath_callback.

From ( http://code.google.com/apis/gdata/docs/auth/oauth.html )

Retrieving a Token from a Callback URL

Google , oauth_token "oauth_callback_url" URL . URL- oauth .

Google OAuth, .

import com.google.gdata.client.docs.*;
import com.google.gdata.client.authn.oauth.*;

String CONSUMER_KEY = "example.com";
String CONSUMER_SECRET = "abc123doremi";

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
oauthParameters.setScope("https://docs.google.com/feeds/");
oauthParameters.setOAuthCallback("http://www.example.com/UpgradeToken.jsp");

GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(new OAuthHmacSha1Signer());
oauthHelper.getUnauthorizedRequestToken(oauthParameters);

, , JSP. Frameworks.

oauthParameters.setOAuthCallback() - , Google URL- , .

+1

Source: https://habr.com/ru/post/1739049/


All Articles