0

このガイドに従ってGoogle OAuth 2.0 認証を使用しましたが、アプリケーションでアクセスとリフレッシュ トークンを取得するリクエストを実装する方法がわかりません。そのガイドが言うように、コードは現在のものです:

// Request an access token    
OAuthAuthorization authorization = new OAuthAuthorization(
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token");
TokenPair tokenPair = await authorization.Authorize(
        ClientId,
        ClientSecret,
        new string[] {GoogleScopes.CloudPrint, GoogleScopes.Gmail});


// Request a new access token using the refresh token (when the access token was expired)
TokenPair refreshTokenPair = await authorization.RefreshAccessToken(
        ClientId,
        ClientSecret,
        tokenPair.RefreshToken);

一般的な Windows Phone アプリケーションでこの関数をどこでどのように呼び出すことができますか?

(この質問が重複している場合は申し訳ありませんが、検索しようとすると、一般的な Google Apis ガイドへのリンクしか回答として見つかりません)

4

1 に答える 1

1

必要なとき (トークンを取得する必要があるとき) に呼び出します。その後、公式の Google ライブラリを使用して API にアクセスし、TokenPair からデータを提供します。さらに、プロジェクトでこれ ( https://github.com/pieterderycke/MobileOAuth/blob/master/MobileOAuth/GoogleScopes.cs ) を取得して、GoogleScopes を使用できるようにしてください。

于 2013-08-23T11:19:22.063 に答える