Extract Google API Bearer Token

Hi All,

I have been trying for some time now to use UiPath to generate a Google API Bearer token. This is done automatically by the smart coding done on the Gsuite activity and I have seen a previous post where another user wanted to receive the output token from the Application Scope authentication so that it can be passed on but due to security concerns, the answer was no.

I find myself in a similar scenario where I would like to use BigQuery to send data to. I have managed to build an automation that can convert a data table into the JSON body needed to insert the data into BigQuery. I have also been able to test this using the Google OAuth2 Playground to generate a Bearer Token and provide this in the header of the API call. However, these are throw away tokens and I need to use a service account instead.

Where I am stuck, and with no programming experience, is constructing the JWT for the service account I want to use, more specifically the Signing of the encoded header and claims set using the p12 key and SHA256withRSA. If I could crack this part (using UiPath or InvokeCode within UiPath) then I would not need you to output the token.

This is what I have been working with: Utiliser OAuth 2.0 pour l'authentification serveur à serveur  |  Google Identity  |  Google Developers

Any help or a point in the right direction would be greatly appreciated

1 Like

Hello @Gerard_McNamara_Ged!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

  5. Meet us and our users on our Community Slack and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff

Hi,
Where you ever able to generate a bearer token for use in API calls in UiPath? I’m trying to get google location reviews and I can make it work in Postman but in UiPath I have not yet been able to get the token. I’m trying to use a scope of https://www.googleapis.com/auth/business.manage for the calls.

Share with us some screenshots from Postman in order to see a successful call for an access_token.

Also, you can generate the HTTP code snippet from Postman.

Then, the same HTTP post request should be adapted for the HTTP Request activity in UiPath Studio.

Postman is not the same as UiPath. The API calls have a redirect uri that if I point to postman it does the hand shake and ultimately returns the bearer token. UiPath can’t do that hand shake and when I look at the reply from google in Fiddler It actually is attempting to point me to a Google logon page.
Postman requests is like this:
https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=client_id&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbusiness.manage&redirect_uri=https%3A%2F%2Fwww.getpostman.com%2Foauth2%2Fcallback
In UiPath I only get the HTML for the Google sign in page…
Google does Not make it easy to call their APIs using http :frowning:

In this case, you can be creative, and create a PowerShell/Python/Bat script that will do all the needed calls in order to retrieve the access_token.
In UiPath you will invoke that process/code that you have created in order to retrieve the access_token and pass it into a variable.

Then, in the end, you can use the HTTP Request activity as normal.

Let us know if this helped.

1 Like