I keep running into "invalid scope" error while enabling "Google Keep API"
I've tried other APIs like "Google drive API" with same code and it worked,but fail for google keep.
I search on Internet,it seems that I need to have "Google Workspace"account to enable it,is that true?
I use .netcore3.1 mvc to implement the Oauth2.0 authentication but it failed for Google Keep....
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using test_coremvc.Models;
using Google.Apis.Auth.AspNetCore3;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Services;
using Google.Apis.Keep.v1;
namespace test_coremvc.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[GoogleScopedAuthorize(KeepService.ScopeConstants.Keep)]
public async Task<IActionResult> KeepFileList([FromServices] IGoogleAuthProvider auth)
{
GoogleCredential cred = await auth.GetCredentialAsync();
var service = new KeepService(new BaseClientService.Initializer
{
HttpClientInitializer = cred
});
//var files = await service.Files.List().ExecuteAsync();
//var fileNames = files.Files.Select(x => x.Name).ToList();
return View();
}
}
}