用.Net调用GoogleAPI获取Google Task列表失败

巴扎黑
풀어 주다: 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

You can email the developer of this application at:jipen...@gmail.com

Some requested scopes were invalid. {invalid=[Tasks]}

   


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!