OAuth Java中的经过身份验证的请求

ele*_*tor 5 java authentication oauth request

如果有人在此代码中使用http://oauth.googlecode.com/svn/code/java/core/和示例服务器的经验,也许您可​​以向我解释如何实现Authenticated Requests处理?参考:http://tools.ietf.org/html/rfc5849#section-3

因此,当用户通过身份验证并且受保护的资源服务器只想确认针对OAuth提供程序的真实性时.

Muh*_*riq 2

从 Google API 控制台创建一个新项目并获取客户端 ID 和密钥。https://code.google.com/apis/console

按照此示例https://code.google.com/p/google-api-java-client/wiki/OAuth2Draft10作为开发 Google OAUTH 客户端插件的帮助。

确保您已根据需要更改了范围、回调 URL 和缩短 URL 等。

private static final String SCOPE = "https://www.googleapis.com/auth/urlshortener";
private static final String CALLBACK_URL = "urn:ietf:wg:oauth:2.0:oob";
...


GenericUrl shortenEndpoint = new GenericUrl("https://www.googleapis.com/urlshortener/v1/url");
Run Code Online (Sandbox Code Playgroud)

此页面将帮助您了解身份验证和授权流程https://developers.google.com/accounts/docs/OAuth2

对 Google OAUTH 有帮助的事情

OAuth 2.0 Playground
Run Code Online (Sandbox Code Playgroud)

很棒的游乐场。这将使您的应用程序进行 OAuth 并获取您想要的信息。换句话说,您可以看到您的应用程序将如何针对 OAUTH 运行,以及为 Google 编写 OAUTH 代码需要哪些信息。https://developers.google.com/oauthplayground/

Verify Access Token
Run Code Online (Sandbox Code Playgroud)

从此 URL 验证您的访问令牌https://www.googleapis.com/oauth2/v1/tokeninfo?access_token= * **