# OpenAPI connection

**URL:** https://discourse.nodered.org/t/openapi-connection/92679
**Category:** General
**Tags:** security
**Created:** [26 October 2024 01:07 UTC](https://discourse.nodered.org/t/openapi-connection/92679 "2024-10-26T01:07:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ryanprel](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@ryanprel](https://discourse.nodered.org/u/ryanprel)
#### Post date: [26 October 2024 01:07 UTC](https://discourse.nodered.org/t/openapi-connection/92679/1 "2024-10-26T01:07:26Z")

</div>

@2WeltenChris

I'm working on connecting up to a Swagger API from SensorPush (Documentation: [Gateway Cloud API — SensorPush](https://www.sensorpush.com/gateway-cloud-api)). I'm having some troubles figuring out how to do the Authentication and Authorization Process prior to pulling in data from the API. None of the examples that I can find show that authentication process. Any advice on how to set things up in this scenario?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [26 October 2024 16:08 UTC](https://discourse.nodered.org/t/openapi-connection/92679/2 "2024-10-26T16:08:57Z")

</div>

Hi @ryanprel

Given this API seems to be using OAuth2, my goto is the OAuth2 Node.

> **[node-red-contrib-oauth2](https://flows.nodered.org/node/node-red-contrib-oauth2?ref=geeek.org)**
>
> The node-red-contrib-oauth2 is a Node-RED node that provides an OAuth2 authentication flow. This node uses the OAuth2 protocol to obtain an access token, which can be used to make authenticated API requests.

Steps.

- Use The OAuth2 node to grab a token (requires the URI, Username, Password, Intent)
- Use the returned token in subsequent calls to the API (Dedicated Nodes, HTTP Node etc etc)

The OAuth2 node works really well.

---

<div class="post-metadata">

### Author: ![meijey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meijey/32/96575_2.png) [@meijey](https://discourse.nodered.org/u/meijey)
#### Post date: [28 October 2024 08:11 UTC](https://discourse.nodered.org/t/openapi-connection/92679/3 "2024-10-28T08:11:55Z")

</div>

Hi @ryanprel,

as I have no account for that API this is theoretical, but should work like this:

Get your token by using this operation with your email and password.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e11acde8f7822cdcc680b95b5fa1470063d5780.png)

EDIT: You will receive an token which must be used with the AcessToken Api.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/49061b37abfa5a3d7e3f54a5b84cf233a6749a2f.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9dcea157fc98c1952ebfc173b3ea56237a1f7c5a.png)

The token received should be put into into your header -\> you can use the new custom header function in the "advanced tab". Like the image below.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d9f8db58680f100c39d03983c2f41cf1eec8461.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9cc902ad82b7e9353fe3fc538faa28cfbd226fdb.png)

Be aware: Saving the email/password/token as a string means it will be saved in your flow.json. I recommend using env variables for your login (email and password) and saving the token temporarily into the flow or global context.

PS: This operation should get you the access token directly

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbe8c777b82e7f509b75366497c24198795c63d8.png)

---

<div class="post-metadata">

### Author: ![2WeltenChris](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/2weltenchris/32/12292_2.png) [@2WeltenChris](https://discourse.nodered.org/u/2WeltenChris)
#### Post date: [13 November 2024 13:15 UTC](https://discourse.nodered.org/t/openapi-connection/92679/4 "2024-11-13T13:15:53Z")

</div>

Sorry - wasn't online in the forum for some time. Did you manage to fix your problem? If not, feel free to open a ticket in gitlab.

---

<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: [11 February 2025 13:16 UTC](https://discourse.nodered.org/t/openapi-connection/92679/5 "2025-02-11T13:16:47Z")

</div>

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