2017-04-25 204 views
-2

enter image description here我想在.net核心中使用谷歌身份验证,但它给我错误 - oauth状态丢失或无效。谷歌身份验证 - 。核心 - oauth状态丢失或无效

请建议我在做什么错

+0

如何地狱是我们应该知道,当你有代码0的例子吗? – ThePerplexedOne

+0

提供有关何时发生问题的更多信息,并最终提供一些代码。 –

+0

请参阅我的应用程序startup- http://stackoverflow.com/questions/43607514/google-authentication-exception-no-authentication-handler-is-configured-to-hand – amethianil

回答

0
//For google client.... 
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) 
     { 
      credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
       GoogleClientSecrets.Load(stream).Secrets, 
       new[] { BooksService.Scope.Books }, 
       "user", CancellationToken.None, new FileDataStore("Books.ListMyLibrary")); 
     } 

// Create the service. 
     var service = new BooksService(new BaseClientService.Initializer() 
      { 
       HttpClientInitializer = credential, 
       ApplicationName = "Books API Sample", 
      }); 
    var bookshelves = await service.Mylibrary.Bookshelves.List().ExecuteAsync(); 
     ... 
    } 

Thats the example of how you can create google client and service to make google authentication 
+0

如果您有任何问题#amethianil ..评论我 –

+0

我已经创建了Google身份验证部分,请在这里查看我的startup.cs类设置 - http://stackoverflow.com/questions/43607514/google-authentication-exception-no-authentication -handler-is-configured-to-hand 当它从google重定向,然后显示这个错误 - oauth状态丢失或无效 我已经在.net中执行了它的工作正常,但在.net核心不工作 – amethianil