>  기사  >  백엔드 개발  >  .Net을 사용하여 GoogleAPI를 호출하여 Google 작업 목록을 가져오지 못했습니다.

.Net을 사용하여 GoogleAPI를 호출하여 Google 작업 목록을 가져오지 못했습니다.

巴扎黑
巴扎黑원래의
2016-12-20 09:22:061870검색

코드는 다음과 같습니다

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<NativeApplicationClient>(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 오류:valid_scope

이 애플리케이션 개발자에게 이메일을 보낼 수 있습니다:jipen...@gmail.com

일부 요청된 범위가 잘못되었습니다. {invalid=[Tasks]}

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.