GSuite - Gmail Activity Unauthorized client error

Did you setup the OAuth account as it is written in the workflow’s annotation and then added the credential to Orchestrator?

Yes, I also use your sample with my asset of credentials on orchestrator.
Both have same error.

@MubieSam_Lin
I tried the workflow again using a completely new account and credential created just now, and it worked fine.
Could you please try with a different account to see if it works?

1 Like

Hi @Mateus_Cruz
Finally I got it working with a new account and learned the lesson, thank you very much!
One last question, the only way to make this process via unattended robot (it is not possible now because OAuth verification), is to submit for OAuth consent screen verification, right?

Good to hear you got it working!

OAuth is a bit difficult to be completely unattended because of the consent screen. It doesn’t come up everytime, but if the token expires, then it’ll appear again.
So you might want to keep that in mind when designing your solution.

1 Like

Hi @Mateus_Cruz

Sorry to bother you again. While trying to setup the OAuth client ID for our new project, found that there is no “other” application type any more as you had indicated before in your GSuiteActivitiesOAuthSample.zip

Seems there are some changes in getting GSuite Activities to work, where I can find the updated instruction to setup OAuth, or better to use Service Account if we will use it for gmail and gsheets of the same user only?

Thanks

Hello! You can choose “Desktop app” as application type and it should work.
I’ve updated the samples to the new version of the G Suite activities and also updated the instructions in them:
GSuiteActivitiesServiceAccountSample-20200709.zip (11.7 KB)
GSuiteActivitiesOAuthSample-20200709.zip (11.5 KB)
GSuiteActivitiesAPIKeySample-20200709.zip (3.8 KB)

1 Like

Hey MubieSam_Lin,

I have created a series on youtube explaining everything about GSuite. may be it can help

1 Like

Hello, I didn’t succeed to use service account access. The connection doesn’t work… Did you configure some other element before ? Btw is the service account a good solution for unattended robot ?
Thank you

Hi Alix,
I’ve been struggling with Service Accounts for Gsuite over the last few weeks but finally managed to get it working! I can confirm that the Service Account works great with unattended robots.

There’s a couple of things you need to keep in mind:

  • Service Account can not be used with Gmail account, only with Gsuite (the paid Google services). This is because you need to “Delegate domain wide access” in order for the Service Account to work, and this is not possible in Gmail.
  • If using Gsuite you should follow the steps below. I’ve written them from the top of my head, so please let me know if I missed anything…
  1. Enable Gmail API (only follow “enable APIs” from here, not “create credentials”. That will be explained more clearly in links 2 and 3.) https://docs.uipath.com/activities/docs/about-google-gsuite-activities#enable-apis
  2. Create Service Account (and download JSON keyfile) Using OAuth 2.0 for Server to Server Applications  |  Google Identity  |  Google Developers
  3. Enable Domain Wide Delegation for the Service Account, copy the Client ID
    image
    and
    image
  4. Ask your Gsuite admin to allow the Domain Wide Delegation (send him the Client ID). It took me a while to find out that you have to enable Domain Wide Delegation both on your own end, as well as on the Admin side. Uso de OAuth 2.0 para aplicaciones de servidor a servidor  |  Plataforma de identidad en Google  |  Google Developers
  5. I think this is it, but I vaguely remember having to set up the Oauth consent screen in GCP as well. If you have to configure the consent screen, just put Application Type = public, make up a name, and put your e-mail as Support Email. The consent screen won’t be shown, as you’re using a Service Account which is pre-authenticated.

Please let me know if this was of any help, and if you managed to get through.

Strangely, the Gsuite activities are working fine with 1.3.0 but not working thru 1.8.0.
When using 1.8.0 version the following error is occurring “Find Files and Folders: Error:“unauthorized_client”, Description:“Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.”, Uri:“””.
While same activity is working fine with 1.3.0 version. Uipath studio and robot is 2019.4.4.

I used your OAuth sample and it worked great for me. BTW, “Other” is no longer an option for application type and so I used Desktop application.

Hi, you are using OAuth2 which prompts authentication consent page every run. How does this fix issues in unattended robots?