Do I must have "Google Workspace" account to enable "Google Keep API"?

463 views Asked by At

I keep running into "invalid scope" error while enabling "Google Keep API"

1 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();
        }
    }
}
1

There are 1 answers

0
Chen On BEST ANSWER

Google Keep API is an enterprise-only API used to create and manage the Keep notes within your domain, including resolving issues identified by CASB software.

In addition, the official documentation shows that you need to create a service account and authorize it. A service account is a special kind of account used by an application, rather than a person. You can use a service account to access data or perform actions by the robot account, or to access data on behalf of Google Workspace or Cloud Identity users.

So, it may only work with Google Workspace domain accounts.

We recommend you use the service account method, but if you don't want to create a service account, you can refer to Gabriel Carballo's answer to use the admin-approved method (tip: I have not verified this method, just as a suggestion).