Dmitry
Dmitry

Reputation: 23

Request had insufficient authentication scopes. [403]. Google People API

I have method who creates the contact and sends the request. After call Execute() method, an excepted appears. How to correctly send changes in Google contacts?

private readonly PeopleServiceService _peopleService;
private readonly string[] _scopes = { PeopleServiceService.Scope.Contacts };

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                secrets,
                _scopes,
                userName,
                CancellationToken.None).Result;

_peopleService = new PeopleServiceService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "ApplicationName",
            });

var contactToCreate = new Person
            {
                Names = new List<Name>
                {
                    new Name
                    {
                        DisplayName = "John"
                    }
                },
                PhoneNumbers = new List<PhoneNumber>
                {
                    new PhoneNumber
                    {
                        Value = "+7 777 777 7777"
                    }
                }
            };

var request = new PeopleResource.CreateContactRequest(_peopleService, contactToCreate);
request.Execute(); // Exception here

That exception: enter image description here

Upvotes: 2

Views: 1542

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116868

insufficient authentication scopes.

Means that you dont currently have the permission to do what you are trying to do.

Method: people.createContact requires the following scope of permissions in order to exicute.

https://www.googleapis.com/auth/contacts

You apear to be using that. So one of two things is happening here.

  1. You have changed the scope in your code and failed to logout and reauthenticate the script in order to get the new permissions.
  2. there is some bug in the api. I have tested it and the API appears to be working.

Double check your code make sure your using that Scope then try and login again.

Upvotes: 2

Related Questions