我正在尝试使用提供的 .NET SDK 在 google 中进行授权,但由于“凭据无效”错误而失败。我找到了这个答案
Google Calendar V3 2 Legged 身份验证失败
但我仍然不明白错误在哪里。看起来一切都按照描述完成。
这是我的代码
const string CONSUMER_KEY = "mytestdomain.com";
const string CONSUMER_SECRET = "my_consumer_secret";
const string TARGET_USER = "user";
const string SERVICE_KEY = "some_api_key";
var auth = new OAuth2LeggedAuthenticator(CONSUMER_KEY, CONSUMER_SECRET, TARGET_USER, CONSUMER_KEY);
var service = new DriveService(auth) { Key = SERVICE_KEY };
var results = service.Files.List().Fetch();
Console.WriteLine(results.Items.Count);
这是来自谷歌控制面板的截图。我刚换了domain name,consumer key和api key。
Manage API client access页面
截图
Manage OAuth key and secret for this domain页面
截图
API Access页面截图Google API console
