有谁知道 Oauth 与谷歌数据 API 一起使用的任何 Web 应用程序示例?
问问题
4397 次
1 回答
1
据我了解(如果我错了,请纠正我)。为了取回请求令牌,请将 设置为oauth_callback
将oauth_token
附加到oath_callback
.
来自(http://code.google.com/apis/gdata/docs/auth/oauth.html)
从回调 URL 中提取令牌
当 Google 重定向回您的应用程序时,oauth_token 将作为查询参数附加到“oauth_callback_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 中编写的。您可以使用框架来使用它。
这oauthParameters.setOAuthCallback()
是 Google 添加回调 URL 路径以确保返回其令牌的地方。
于 2010-03-30T21:21:20.847 回答