-
Notifications
You must be signed in to change notification settings - Fork 77
Unable to use this provider, always 'Request had insufficient authentication scopes' #168
Comments
I believe what is crucial is the fact that you can't directly access the Directory API from GCP. Only a Google Workspace user with enough rights can do that. And that's why the GCP account you use to access the API (wether a user or a service account) must |
@codedbypm thanks for the response. I feel like I should have rights to access the API, which is why I'm confused. I've gone over the related documentation here and on Google's side several times, and verified that everything is setup correctly (as best I can tell, anyways). Do you know of a simple example for validating the correct access rights? For example, a |
Unfortunately I don't think there is a gcloud command for that. But can't confirm that. |
@codedbypm thanks for the additional information, and sorry for the delayed response. Just to confirm this bit:
This should definitely be the case as my personal account has these rights as verified in the roles page of my Google Workspace user. This is the same account that I setup via Are you not using a GCP service account at all for this task; just the Google Workspace account? Today I finally found some time to try this again. I removed all of the services accounts, domain wide delegation integration, etc that I created as part of the initial setup and started from scratch. Unfortunately, I ended up in the exact same situation with the same error. One new piece that I don't recall running into before is now when I set the impersonated email address, I get a different error. This time it looks like it is trying to contact the GCP metadata server and fails. I'm running everything from my laptop locally, and I'm not sure why this happens when setting the impersonated email address. Perhaps it assumes this option is only used when running from within GCP? I haven't yet found any options that are associated with this behaviour.
If it isn't too much trouble and you're using the GCP service account integration path, could you possibly share the Oauth scopes you're assigning in Google Workspace Domain-wide Delegation for you API client? I'm using the following as described as minimum requirements in the documentation:
I would assume that if the impersonation email worked correctly, I would be using the service account linked to the API client ID that I created following the Google documentation which would be similar to |
That is indeed new per #171 |
I use a service account from my GCP project, which has Domain Wide Delegation enabled. This is instead a special GWorkspace user I created that has access to the Directory API. Its email address is the one I fill in for the |
@codedbypm Thanks for the details, and sorry for the delay. The notification got lost in my email =\ Hmm. This is very odd. I feel like what you're showing me is exactly what I have done aside from the dedicated account for impersonation. In any case it is helpful to see a working example. I might try to exactly replicate what you've demonstrated to see if that solves the problem, then work backwards to see what I'm missing. @DeviaVir Thanks for clarifying. The new error would probably be more helpful in tracking down where the process is failing at the very least. Thanks again for the assistance! |
@lhriley hi, not sure what exactly is the problem but I wrote an example of how to authenticate with gworkspace using this provider. The user account needs admin permissions (e.g. Super admin or at least Groups- and User management admin, see https://support.google.com/a/answer/2405986?hl=en) maybe this helps with debugging. |
@jazzlyn Thanks for the example to work from. I'm also unclear what the root cause of this issue is. I'll test out your example code once I get the opportunity to, but I'm actually starting a vacation tomorrow so it might be a while before I circle back to this. Thanks again. |
I also experienced this issue and struggled for several hours wrestling with it. In the end I found a solution I can share in case it helps others: I specifically wanted to use a user account which had sufficient admin privs in my workspace rather than use a service account. For my localized development of this project, it seemed like a good idea to use short-lived credentials, and that is echoed in the following links:
Cutting to the punchline, what worked for me was making sure to include the
In my case above I just started experimenting with this provider using the Without specifying the This link was helpful for setting up OAuth2 and finding access to the project's client id and secret. ------ edit 1: I meant to point out that after performing the above command, my project worked with a very simple provider config -- No need for any arguments:
Hope that provides enough breadcrumbs to help others out. Cheers |
Hello,
I've been stuck on this for a while now, and I'm really not clear on what I could be doing wrong. I've tried setting up my credentials based on the documentation here: https://github.com/DeviaVir/terraform-provider-gsuite/blob/v0.1.58/website/docs/index.html.markdown#best-practices
I've tried using a service account (as recommended) as well as my own account using the credentials from
gcloud auth login
. My account is a Super Admin in both Google Workspace as well as GCP, and I have successfully used thegcloud
CLI, Python and Terraform to manage resources in GCP. The only time I run into an issue is using thisgsuite
provider.Additionally, I've used many different combinations of the
oauth_scopes
as documented. Further, I've tried completely unsetting theoauth_scopes
as suggested when using a personal admin account. No combination seems to make any difference.No matter what I do or do not pass to the provider directly or through environment variables I always get the error:
In the debug logs the response always looks like this:
The text was updated successfully, but these errors were encountered: