Der Code lautet wie folgt
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); }
Beim Ausführen von
Process.Start(authUri.ToString()); ist das Ergebnis:
OAuth2.0-Fehler: invalid_scope
Sie können dem Entwickler dieser Anwendung eine E-Mail senden an:jipen...@gmail.com
Einige angeforderte Bereiche waren ungültig. {invalid=[Aufgaben]}