简体   繁体   中英

Google Authentication- .Net core - The oauth state was missing or invalid

在此处输入图片说明 I am trying to use google authentication in .net core but its giving me error - The oauth state was missing or invalid.

Please suggest what i am doing wrong

//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 

Maybe, the problem is that you incorretly set the googleOptions.CallbackPath . Try this answer. It helped me. https://stackoverflow.com/a/61950614/9547346

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM