Java 谷歌OAuth2游乐场返回“;“未经授权的客户”;
我的授权码请求:Java 谷歌OAuth2游乐场返回“;“未经授权的客户”;,java,web-applications,oauth-2.0,google-oauth,oauth2client,Java,Web Applications,Oauth 2.0,Google Oauth,Oauth2client,我的授权码请求: clientId = xxxxxx clientSecret = xxxxxxxx applicationHost = xxxxxxxxx 我得到了一个授权码。但是,每当我使用此代码发送访问令牌请求时,我都会收到一个错误。(代码400) 我的访问令牌请求: OAuthClientRequest oAuthClientRequest = OAuthClientRequest .authorizationProvide
clientId = xxxxxx
clientSecret = xxxxxxxx
applicationHost = xxxxxxxxx
我得到了一个授权码。但是,每当我使用此代码发送访问令牌请求时,我都会收到一个错误。(代码400)
我的访问令牌请求:
OAuthClientRequest oAuthClientRequest = OAuthClientRequest
.authorizationProvider(OAuthProviderType.GOOGLE)
.setResponseType("code")
.setClientId(clientId)
.setParameter("access_type", "online")
.setRedirectURI(applicationHost + "auth/google/callback")
.setScope("https://www.googleapis.com/auth/plus.login")
.buildQueryMessage();
response.sendRedirect(oAuthClientRequest.getLocationUri());
OAuth2游乐场响应:
OAuthClientRequest oAuthClientRequest = OAuthClientRequest
.tokenProvider(OAuthProviderType.GOOGLE)
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setClientId(clientId)
.setClientSecret(clientSecret)
.setParameter("access_type", "online")
.setRedirectURI(applicationHost + "auth/google/callback")
.setCode(code)
.buildQueryMessage();
GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(
oAuthClientRequest, GitHubTokenResponse.class);
return oAuthResponse.getAccessToken();
请帮帮我。提前感谢。您正在从应用程序(即客户端id XXXXX)中获取一个身份验证代码,并将其粘贴到另一个应用程序(客户端id为YYYY的oauth Playway)中,是否希望它能正常工作 那不行 如果您进入Gear选项并输入应用程序的凭据,它可能会起作用。但我有点不明白你为什么这么做。你想解决的问题是什么
这个答案可能有助于oauth Playway在提供授权代码时生成一个访问令牌和一个刷新令牌。我基本上想用授权代码生成一个演示访问令牌。即使我运行我的代码(检查access_token request部分)并发送http请求,我仍然会得到错误代码400。我的目标是让用户能够通过facebook、google、twitter等进行登录。我已经成功使用facebook,但google出了一些问题。哦,非常感谢Oauth Playerd链接。它缺少我自己的配置。
HTTP/1.1 400 Bad Request
Alternate-protocol: 443:quic
Content-length: 37
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Via: HTTP/1.1 GWA
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Mon, 17 Feb 2014 09:03:52 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json
Expires: Fri, 01 Jan 1990 00:00:00 GMT
{
"error": "unauthorized_client"
}