Google app engine oauth问题(应用程序引擎)

Google app engine oauth问题(应用程序引擎),google-app-engine,oauth,Google App Engine,Oauth,我正在尝试使用oauth从google文档中提取用户文档数据, 但是我不知道怎么做 -oauth_验证器的用途是什么 -如何获取访问令牌密钥? -如果我尝试使用下面的DocsService,则会出现“服务器错误” -有明确的指南吗?我找不到自动取款机。 String oauth_verifier = req.getParameter("oauth_verifier"); String oauth_token = req.getParameter("oauth_token");

我正在尝试使用oauth从google文档中提取用户文档数据, 但是我不知道怎么做
-oauth_验证器的用途是什么
-如何获取访问令牌密钥?
-如果我尝试使用下面的DocsService,则会出现“服务器错误”
-有明确的指南吗?我找不到自动取款机。

    String oauth_verifier = req.getParameter("oauth_verifier");
    String oauth_token = req.getParameter("oauth_token");
    String oauthtokensecret = req.getParameter("oauth_token_secret");

    GoogleOAuthParameters oauthparam = new GoogleOAuthParameters();
    oauthparam.setOAuthConsumerKey("consumer key");
    oauthparam.setOAuthConsumerSecret("secret");
    oauthparam.setOAuthToken(oauth_token);
    oauthparam.setOAuthTokenSecret(oauthtokensecret);
    oauthparam.setOAuthVerifier(oauth_verifier);

    OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();
    GoogleOAuthHelper oauthhelper = new GoogleOAuthHelper(signer);
    String accesstoken = "";
    String accesstokensecret = "";

    try {
        oauthhelper.getUnauthorizedRequestToken(oauthparam);
        accesstoken = oauthhelper.getAccessToken(oauthparam);
        accesstokensecret = oauthparam.getOAuthTokenSecret();
//DocsService客户端=新的DocsService(“yourCompany-YourAppName-v1”);

这些可能不是您想要的,因为它们是特定于OAuth的,与google无关,但我发现这些“入门”文章非常有用:


结果表明,我需要获取oauth\u令牌\u机密,然后重新使用它。 So(在将用户重定向到google登录页面之前)

然后,在用户授予访问权限并将我们重定向到oauth_回调url之后:

oauthparam.setOAuthToken(oauthtoken);
oauthparam.setOAuthVerifier(oauthverifier);
oauthparam.setOAuthTokenSecret(OAuthTokenSecret.tokenSecret);
oauthhelper.getAccessToken(oauthparam); // access token and access token secret are saved in oauthparam.
// access google service..
GoogleService googleService = new GoogleService( "cp", "test222");
googleService.setOAuthCredentials(oauthparam, signer);
BaseFeed resultFeed = googleService.getFeed(feedUrl, Feed.class);
oauthparam.setOAuthToken(oauthtoken);
oauthparam.setOAuthVerifier(oauthverifier);
oauthparam.setOAuthTokenSecret(OAuthTokenSecret.tokenSecret);
oauthhelper.getAccessToken(oauthparam); // access token and access token secret are saved in oauthparam.
// access google service..
GoogleService googleService = new GoogleService( "cp", "test222");
googleService.setOAuthCredentials(oauthparam, signer);
BaseFeed resultFeed = googleService.getFeed(feedUrl, Feed.class);