# How to add key in open api client?

**URL:** <https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486>\
**Category:** General\
**Created:** [12 November 2022 09:01 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486 "2022-11-12T09:01:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanshiiii](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@himanshiiii](https://discourse.nodered.org/u/himanshiiii)\
**Post date:** [12 November 2022 09:01 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/1 "2022-11-12T09:01:14Z")

</div>

My question is related to node red openapi client i have used "npm install openapi-red" to install openapi red.  
I am using openapi client to show my result but it shows an error of

```auto
 {
   "error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account",
   "results" : [],
   "status" : "REQUEST_DENIED"
} 

```

so i add key value on function node using

`msg.openapiToken=" hdgfuiehedjwenishuiew" `

(it's just an example) but it still shows the same error as i mentioned above so i  
tried

`msg.headers = { "key" :"key_value"}`

but still shows the same error . So please tell me what should i do to solve this error or what i have to use to resolve this error.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 November 2022 09:17 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/2 "2022-11-12T09:17:51Z")

</div>

Do you have a valid [API key from Google](https://developers.google.com/maps/documentation/javascript/get-api-key)?

> ## Create API keys
> 
> The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.

---

<div class="post-metadata">

**Author:** ![himanshiiii](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@himanshiiii](https://discourse.nodered.org/u/himanshiiii)\
**Post date:** [12 November 2022 17:10 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/3 "2022-11-12T17:10:03Z")

</div>

Yes I have

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 November 2022 17:33 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/4 "2022-11-12T17:33:21Z")

</div>

I edited your first post so it would be easier to read, Hopefully someone with knowledge of the Google API will chime in (I don't use Google)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [12 November 2022 18:37 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/5 "2022-11-12T18:37:38Z")

</div>

The documentation of the node describes:

> 1. Authentification

> If the API requires an authentification token you can log in using the standard `http-request`node of Node-RED. The JWT token you get as a response must then be put into `msg.openApiToken` to be automatically placed in the request-header as bearer authentification. In case you would like to use a different authentification than bearer, you can use `msg.headers` as you can do with the default http request node of Node-RED.  
> Both message object will be deleted afterwards if you do not set the option "Keep authentification".

In short:

- first post a request with your key to the API.
- the response will be a JWT token.
- the JWT token needs to be provided to the open-api node as `msg.openApiToken`

---

<div class="post-metadata">

**Author:** ![himanshiiii](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@himanshiiii](https://discourse.nodered.org/u/himanshiiii)\
**Post date:** [14 November 2022 08:43 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/6 "2022-11-14T08:43:34Z")

</div>

I am actually doing this but I am not getting the result as I am excepting And now I am not able to do this

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 January 2023 08:44 UTC](https://discourse.nodered.org/t/how-to-add-key-in-open-api-client/70486/7 "2023-01-13T08:44:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
