Digital Exchange

last person joined: 20 hours ago 

This community is a place to discuss the Blue Prism DX and all of the assets hosted there.
Expand all | Collapse all

Precondition check failed error using Gmail API v1

  • 1.  Precondition check failed error using Gmail API v1

    Posted 08-27-2020 18:55
    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
    ------------------------------


  • 2.  RE: Precondition check failed error using Gmail API v1

    Posted 08-28-2020 09:45
    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  

    Google JWT Credentials


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



  • 3.  RE: Precondition check failed error using Gmail API v1

    Posted 08-28-2020 19:00
    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
    ------------------------------



  • 4.  RE: Precondition check failed error using Gmail API v1

    Posted 08-28-2020 20:13
    It looks like I spoke to soon. 😭 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:



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



  • 5.  RE: Precondition check failed error using Gmail API v1

    Posted 09-03-2020 11:03
    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
    ------------------------------



  • 6.  RE: Precondition check failed error using Gmail API v1

    Posted 09-03-2020 11:32
    Hi @Arthanareeswaran Chandrasekaran​,

    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
    ------------------------------



  • 7.  RE: Precondition check failed error using Gmail API v1

    Posted 09-03-2020 11:53
      |   view attached
    Hi @Eric Wilson: 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
    ------------------------------



  • 8.  RE: Precondition check failed error using Gmail API v1

    Posted 09-03-2020 23:57
    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
    ------------------------------



  • 9.  RE: Precondition check failed error using Gmail API v1

    Posted 09-04-2020 04:36
    Hi, @Arthanareeswaran Chandrasekaran,

    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
    ------------------------------



  • 10.  RE: Precondition check failed error using Gmail API v1

    Posted 09-07-2020 02:28
    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
    ------------------------------



  • 11.  RE: Precondition check failed error using Gmail API v1

    Posted 09-07-2020 02:42
    Hi, @Arthanareeswaran Chandrasekaran,

    this means it works now! Congratulations :)!

    The API call will return JSON which is what you got. I assume you called a function (getProfile) which returns email address, number of messages, number of threads and some historyId.

    So what you want to do with this? - this is important question. Or what do you try to achieve?

    Regards,



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



  • 12.  RE: Precondition check failed error using Gmail API v1

    Posted 09-09-2020 09:03
      |   view attached
    Hi Zdeněk Kabátek: No I am not getting successfull response while executing the APi Call from Blueprism only If  execute the API Call via below link I am getting successful response!

    https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get

    While I execute the code from Blueprism I am getting error as attached in my last thread. Please let me know what I am doing wrong...

    Regards,
    Aadhi.


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



  • 13.  RE: Precondition check failed error using Gmail API v1

    Posted 09-09-2020 09:24
    @Arthanareeswaran Chandrasekaran,

    Lets review a few things.

    1) You've got a subscription (free or otherwise) to Google G Suite?
    2) You've enabled the GMail API in your Google console?
    3) You've created a service account in the Google console under "APIs & Credentials"?
    4) You've added the service account details (email address and private key) to a OAuth 2.0 (JWT Bearer Token) credential in Blue Prism?

    5) You've associated that credential with the Google GMail Web API definition in Blue Prism and updated the Common Authentication details as mentioned previously?

    Cheers,

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