.Net を使用して GoogleAPI を呼び出し、Google タスク リストを取得できませんでした

巴扎黑
リリース: 2016-12-20 09:22:06
オリジナル
1803 人が閲覧しました

コードは次のとおりです

static void Main(string[] args)
        {
            // Register the authenticator. The Client ID and secret have to be copied from the API Access
            // tab on the Google APIs Console.
            var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
            provider.ClientIdentifier = "272908629865.apps.googleusercontent.com";
            provider.ClientSecret = "4UmdiNDILOV5bv-qRQz2XUwA";
            var auth = new OAuth2Authenticator(provider, GetAuthentication);
            // Create the service and register the previously created OAuth2 Authenticator.
            var service = new TasksService(auth);
            TaskLists results = service.Tasklists.List().Fetch();
            foreach (TaskList list in results.Items)
            {
                Console.WriteLine(list.Title);
            }
        }
        private static IAuthorizationState GetAuthentication(NativeApplicationClient arg)
        {
            // Get the auth URL:
            IAuthorizationState state = new AuthorizationState(new[] { TasksService.Scopes.Tasks.ToString() });
            state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
            Uri authUri = arg.RequestUserAuthorization(state);
            // Request authorization from the user (by opening a browser window):
            Process.Start(authUri.ToString());
            Console.Write("  Authorization Code: ");
            string authCode = Console.ReadLine();
            Console.WriteLine();
            // Retrieve the access token by using the authorization code:
            return arg.ProcessUserAuthorization(authCode, state);
        }
ログイン後にコピー

Process.Start(authUri.ToString());を実行すると、ブラウザでの結果は次のようになります:

OAuth2.0エラー:invalid_scope

このアプリケーションの開発者:jipen...@gmail.com

要求されたスコープの一部が無効でした。

ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!