0
    clientId = xxxxxx
    clientSecret = xxxxxxxx
    applicationHost = xxxxxxxxx

私の認証コード要求:

   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());

これで認証コードを取得しています。しかし、このコードを使用して access_token のリクエストを送信すると、エラーが発生します。(コード 400)

私の access_token リクエスト:

    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();

OAuth2 Playground レスポンス:

    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"
    }

私を助けてください。前もって感謝します。

4

1 に答える 1

2

アプリケーションから認証コード (つまり、クライアント ID XXXXX) を取得し、それを別のアプリ (クライアント ID YYYYY の oauth プレイグラウンド) に貼り付けて、それが機能することを期待していますか?

それはうまくいきません。

ギア オプションに移動してアプリの資格情報を入力すると、機能する場合があります。しかし、なぜあなたがこれをしているのか、私は少し混乱しています。あなたが解決しようとしている問題は何ですか?

ユーザーの介入なしでアプリ (Web またはインストール済み) を承認するにはどうすればよいですか? (正規の?)

于 2014-02-18T06:53:57.063 に答える