cancel
Showing results for 
Search instead for 
Did you mean: 

Precondition check failed error using Gmail API v1

StevenCheng
Level 2
Does anyone get it to work?  I get the following error to use gmail.users.messages.list or gmail.users.messages.read.

Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {
"error": {
"code": 400,
"message": "Precondition check failed.",
"errors": [
{
"message": "Precondition check failed.",
"domain": "global",
"reason": "failedPrecondition"
}
],
"status": "FAILED_PRECONDITION"
}
}

------------------------------
Steven Cheng
IT Application Advisor
Celestica Inc.
America/Toronto
------------------------------
15 REPLIES 15

Hi, Steven,

you are lucky guy ;) as I just solved it after 3 almost full days of investigation this morning.

My understanding is following:
1. you need to have G Suite account activated (if you don't have it you can activate it for 14 days for free). So to state it clearly - this will not work for personal gmail account - as long as you are going to use service account.
2. if first step done you need to perform all the steps which are found here https://developers.google.com/admin-sdk/directory/v1/guides/delegation
3. when you import bpskill you need to follow the guide for configuration
4. when all configurations are done you need to change properties of the Common Authentication parameters in Authorization URI and Audience like in the image below. The scope and subject depends on your environment and requirement.
4. after that it should work, at least it worked for me  

8712.png


------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

Changing the Common Authentication definition should not be required, at least it wasn't for me. However, as Zdeněk mentioned, you will have to have a company deployment of G-Suite to test this using a Google Service Account. That means you will also have to have a domain name that you can tie to the G-Suite configuration.

I did continue to receive the 400 error for quite a while after setting up my G-Suite though. I ended up restarting my Blue Prism client a few times and then things started working correctly. Not sure if that was an issue of something having been cached from the initial failed attempts or what. 
 
Cheers,
 


------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

It looks like I spoke to soon. :loudly_crying_face: You do have to set the value of Subject on the Common Authentication page. However, instead of hard coding the value you can set it to the value of the userId input parameter that is required on every method. What this ends up doing is telling Google which specific user the service account is requesting delegated authority for. Here's what my Common Authentication section looks like:

8738.png


------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Zdeněk: I am trying to automate GMail API using the Skill from DX. Can you help me to share any specific guide from Blueprism to perform the list of configurations. I am trying to send my private KEY in Credentials using getProfile action. I am getting error like below.

Internal : Unexpected error PKCS8 data must be contained within '-----BEGIN PRIVATE KEY-----' and '-----END PRIVATE KEY-----'. I tried multiple approach to send the KEY in credential manager in the below format but I am getting same error. Would you able to guide me for this error.

Approach 1: '-----BEGIN PRIVATE KEY-----' myPrivatekey '-----END PRIVATE KEY-----'


------------------------------
Arthanareeswaran Chandrasekaran
Technical Lead/ Architect
IBM
Asia/Singapore
------------------------------

Hi @Arthanareeswara​,

What do yo mean you're using the getProfile action? If you're using the GMail skill from the DX you configure the credential details in Settings -> Security -> Credentials. Enter your Issuer and Private Key information there and then reference that credential within the GMail skill definition on the Common Authentication page.

Cheers,

------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi @ewilson: Thanks for responding. I have updated my API KEY in Credentials under "Google OAuth2 JWT Credential" in below format

'----- BEGIN PRIVATE KEY -----'\n AIza---kuE \n'----- END PRIVATE KEY -----'\n. While Executing getprofile I am getting below error. Can you help me with the exact format to be used for updating the key in credentials. I tried multiple approach but still no luck.

Error Message: "Internal : Unexpected error PKCS8 data must be contained within '-----BEGIN PRIVATE KEY-----' and '-----END PRIVATE KEY-----'.
Parameter name: privateKey".

Attaching the screen shot for your reference from the common authentication. Thanks once agiain for your support.





------------------------------
Arthanareeswaran Chandrasekaran
Technical Lead/ Architect
IBM
Asia/Singapore
------------------------------

Hi BP Community Users: Have anyone encountered the above issue while working with GMail API. If you have any solution can you help me. Thanks...

------------------------------
Arthanareeswaran Chandrasekaran
Technical Lead/ Architect
IBM
Asia/Singapore
------------------------------

Hi, @Arthanareeswara,

please look at the screen shot which I posted in my post. You need to change Authorization URI and Audience fields in Common Authentication. Then as I wrote before you have got G Suite product licensed? I can definitely walk you through it.

Regards,


------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

Hi @Zdeněk Kabátek: Thanks for responding. Yes I am using G-Suite Account and I have made the changes but now I having different error! Not sure what is the issue. I have also tested the API Settings in "https://developers.google.com/gmail/api/reference/" which is working fine.

Here is the response 
{
"emailAddress": "arthaaadhi@visha.page",
"messagesTotal": 7,
"threadsTotal": 7,
"historyId": "1439"
}



------------------------------
Arthanareeswaran Chandrasekaran
Technical Lead/ Architect
IBM
Asia/Singapore
------------------------------