You need to sign in to do that
Don't have an account?

Using named credentials with Google's G-Suite
hi,
I am trying to use Named Credentials to get a list of users from Google's G-Suite.
So I created an app on the Google console and gave it a scope of https://www.googleapis.com/auth/admin.directory.user.readonly
I confirmed with Google's API explorer that both the scope and the URL I was going to make the request on were correct
Then I created an Auth Provider and Named Credential leaving the Scope blank. But when I run this code in anonymous apex, I get an error "Insufficent Permission" returned from Google:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Google/admin/directory/v1/users?domain=ncutraining.ie');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
so I tried adding the scope to the Named Credential and the Auth Provider, but then I get and error Missing_id_token when I try to save the Named Credential.
Has anyone got something similar working I could look at?
thanks
I am trying to use Named Credentials to get a list of users from Google's G-Suite.
So I created an app on the Google console and gave it a scope of https://www.googleapis.com/auth/admin.directory.user.readonly
I confirmed with Google's API explorer that both the scope and the URL I was going to make the request on were correct
Then I created an Auth Provider and Named Credential leaving the Scope blank. But when I run this code in anonymous apex, I get an error "Insufficent Permission" returned from Google:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Google/admin/directory/v1/users?domain=ncutraining.ie');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
so I tried adding the scope to the Named Credential and the Auth Provider, but then I get and error Missing_id_token when I try to save the Named Credential.
Has anyone got something similar working I could look at?
thanks

Found it - when creating the Auth Provider - I used the Google as the provider type, I should have choosen Open ID Connect