5

ここで少し検索しましたが、私の問題に対する答えが見つかりませんでした。

spring-sec-oAuth 2.0 (1.0.0.RC2a)で oAuth クライアントを実装します。beans.xml を適切に設定した後、有効なトークンを喜んで取得し、すべて問題ないように見えます。次に、Calendar API を使用したいのですが、Calendar オブジェクトを取得するための呼び出しを行う方法がわかりません。

私の(関連する)設定:(spring-servlet.xml)

<!--apply the oauth client context-->
<oauth:client   id="oauth2ClientFilter" />

<oauth:resource id="google" 
    type="authorization_code" 
    client-id="<my client id>" 
    client-secret="<my client secret>"
    access-token-uri="https://accounts.google.com/o/oauth2/token" 
    user-authorization-uri="https://accounts.google.com/o/oauth2/auth"
    scope="https://www.googleapis.com/auth/calendar"
    client-authentication-scheme="form"
    pre-established-redirect-uri="https://ohad.sealdoc.com/oauth2-client/hello" />

<bean id="googleClientService" class="com...GoogleClientServiceImpl">
    <property name="butkeDemoRestTemplate">
        <oauth:rest-template resource="google" />
    </property>

および実装クラス:

public class GoogleClientServiceImpl implements DemoService 
{
    private RestOperations butkeDemoRestTemplate;

    @Override
    public String getTrustedMessage() 
    {
        String dataUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer";

        Calendar service = butkeDemoRestTemplate.getForObject(dataUri, Calendar.class);
        return "demo";
    }

}

そうすることで、次のようになります。

リクエストの処理に失敗しました。ネストされた例外は error="invalid_request", error_description="{errors=[{domain=usageLimits, reason=accessNotConfigured, message=Access Not Configured}], code=403, message=Access Not Configured}"

確かに、「getTrustedMessage()」で何か間違ったことをしているので、専門家に相談するようです... OAuth2RestTemplate を使用したいのですが、使用する必要がある URI をどのように知ることができますか? (Google)を検索した後、Googleコードの例のみが見つかりました.Google oAuthを使用しています(これは使用したくありません-クライアントにはSpring実装を使用したいです)

何か案は?

4

1 に答える 1

3

とった!

「サービス」の下の Google API コンソールで特定のサービスを有効にするだけで、この問題 (「403, message=Access Not Configured」を取得) を解決しました...

于 2012-11-10T18:30:13.357 に答える