Google.GoogleApiException:'Google.Apis.Requests.RequestError 请求的身份验证范围不足
我正在尝试使用 Google People API 和 C# 创建 google 联系人。我可以列出联系人。但是装箱联系给了我这个异常
Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Request had insufficient authentication scopes. [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]
Fallowing 是该方法的代码
public static void CreateContact()
{
string m_client_secret = "LIsZiU972ThMyD7.....";
string m_client_id = "....n3vgb1o235m.apps.googleusercontent.com";
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = m_client_id,
ClientSecret = m_client_secret
},
new[] { "profile", "https://www.googleapis.com/auth/contacts" },
"me",
CancellationToken.None).Result;
var service = new PeopleServiceService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "ContactCreatorApp",
});
var contactToCreate = new Person();
var names = new List<Name> { new Name() { GivenName = "Jhon", FamilyName = "Doe" } };
contactToCreate.Names = names;
var request = new PeopleResource.CreateContactRequest(service, contactToCreate);
var createdContact = request.Execute();
}
对我来说它看起来像是范围 new[] { "profile", "https://www.googleapis.com/auth/contacts" 范围内的一些问题}
。尝试了多个范围但没有运气。有人有线索吗?
I'm trying to create a google contact using Google People API and C#. I'm able to list the contact . But crating contact gives me this exception
Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Request had insufficient authentication scopes. [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]
Fallowing is the code for the method
public static void CreateContact()
{
string m_client_secret = "LIsZiU972ThMyD7.....";
string m_client_id = "....n3vgb1o235m.apps.googleusercontent.com";
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = m_client_id,
ClientSecret = m_client_secret
},
new[] { "profile", "https://www.googleapis.com/auth/contacts" },
"me",
CancellationToken.None).Result;
var service = new PeopleServiceService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "ContactCreatorApp",
});
var contactToCreate = new Person();
var names = new List<Name> { new Name() { GivenName = "Jhon", FamilyName = "Doe" } };
contactToCreate.Names = names;
var request = new PeopleResource.CreateContactRequest(service, contactToCreate);
var createdContact = request.Execute();
}
For me It looks like some issue in the scope new[] { "profile", "https://www.googleapis.com/auth/contacts" }
. Tried multiple scopes but no luck. Anyone has a clue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论