I'm using google admin directory API to get all accounts public information using following API https://www.googleapis.com/admin/directory/v1/users
here is link for this api link when I logged in using g suite domain account let say [email protected] with non administrative user this api works fine and fetch the data of all accounts in array but When I call this API by logging in as admin it gives me following error /
Insufficient Permission: Request had insufficient authentication scopes
why its happening Im using same auth and API key for both users
my code is here
const token =localStorage.getItem('token')
fetch(`https://www.googleapis.com/admin/directory/v1/users?
domain=${domain.url}&viewType=domain_public&key=${apiKey.key}`
,{ headers: {
'authorization': 'Bearer '+token
},})
.then(response => response.json())
.then(data => this.setState({ users:data.users }));
token is coming from this module npm react google login google sign in button
view_type
anddomain
here you can look developers.google.com/admin-sdk/directory/v1/reference/users/… @Shulem – Constraintview_type
= domain_public for non admin user – Constraintbearer xxxxx
xxx is access token @Shulem – Constraintfetch
method in reactjs – Constrainthttps://www.googleapis.com/auth/admin.directory.user.readonly
but when i add this scope to admin account it dont work while works for non admin user @Shulem – Constraint