Google Admin Api- User provisioning to Organisational Unit Give Error: 403

209 Views Asked by At

Hi All Geniuses buddies

I am using google admin apis. user provisioning is what i successfully performed. When i try to move the same user to Organisational Unit(OU). It give me error like

{"The remote server returned an error: (403) Forbidden."} You are not authorised to access this api.

I am not able to figure out which api i need to trun on for that. Here are the api i have truned on.enter image description here

This it the code i am using to perform the same

            //Method 1
 OrganizationService serviceNew = new OrganizationService("Domain", "User Provisioning");

 serviceNew.setUserCredentials("Admin Email Account", "Password");


 serviceNew.UpdateOrganizationUser("Customer ID", "The Email Account i want to add", "/OU Name", "/");

I dont know why its not working.

!Any help, It will be appreciated.

2

There are 2 best solutions below

0
On

You have to grant the application access to your domain. In the Admin Console of your domain go to (admin.google.com): Security > Advanced Settings > In the Authentication section go to "Manage API client access"

There you have to add the client name, which is the client id of the app (looks like a long email) and in the field "One or More API Scopes" you have to add the all scopes that your app is using separated by a comma.

0
On

I did some changes to my code. Instead of moving user to Organisation Unit,I just updated it to the Organisation Unit path. And See What it worked like charm. :) Thanks Gerardo, for showing interest. Keep the good work going.