# Node - Oauth2 API \[GOT CREATED\]

**URL:** <https://community.n8n.io/t/node-oauth2-api-got-created/189>\
**Category:** Feature Requests (done)\
**Created:** [October 14, 2019, 9:12am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189 "2019-10-14T09:12:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alxnzx](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/alxnzx/32/195_2.png) [@alxnzx](https://community.n8n.io/u/alxnzx)\
**Post date:** [October 14, 2019, 9:12am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/1 "2019-10-14T09:12:06Z")

</div>

Would it be possible to have a generic Oauth2 API that could be used for services that require it ?

(Examples include HealthMate, Todoist, etc)

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 14, 2019, 6:48pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/2 "2019-10-14T18:48:58Z")

</div>

Yes, I am sure it is possible, not sure how much work it would be though. I would have to look more into it. I was happy that I did not have until now as I do not have much experience with OAuth2. But agree that it would probably be important soon.

---

<div class="post-metadata">

**Author:** ![alxnzx](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/alxnzx/32/195_2.png) [@alxnzx](https://community.n8n.io/u/alxnzx)\
**Post date:** [October 17, 2019, 6:10am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/3 "2019-10-17T06:10:10Z")

</div>

Oauth2 is usually not too complicated to implement, at least on the client side! 😛

With the proper base of authentication, a lot of new nodes could be added to the library quickly (Google APIs, Fitbit, MailChimp, Laravel based devs, Spotify, Discord, Vimeo, Mastodon, StackExchange and so much more).

Can’t wait to see n8n get to the next level, you rock @jan!

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 17, 2019, 7:06am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/4 "2019-10-17T07:06:26Z")

</div>

Ah yes, I guess there are now enough libraries around which help with that. I just remember that I tried to implement it once server-side and that there seemed to be multiple ways to authenticate via Oauth2 and so would also have to support all of them client-side.

Thanks a lot! I also!

---

<div class="post-metadata">

**Author:** ![svenjanssen](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/svenjanssen/32/47634_2.png) [@svenjanssen](https://community.n8n.io/u/svenjanssen)\
**Post date:** [November 11, 2019, 10:36am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/5 "2019-11-11T10:36:23Z")

</div>

What is the current status of Oauth2 implementation? I think it would be a widely used extension useful for many future nodes out there

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [November 11, 2019, 11:31am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/6 "2019-11-11T11:31:02Z")

</div>

Sadly nothing new. Everything is simply still to crazy that I did not have time yet to look into it.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [December 2, 2019, 6:01pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/8 "2019-12-02T18:01:28Z")

</div>

No sadly did not look into libraries yet

---

<div class="post-metadata">

**Author:** ![svenjanssen](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/svenjanssen/32/47634_2.png) [@svenjanssen](https://community.n8n.io/u/svenjanssen)\
**Post date:** [January 6, 2020, 6:46pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/9 "2020-01-06T18:46:11Z")

</div>

What does this need to be implemented? I wonder what we can do to promote this feature, because it’s the foundation for so many nodes

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [January 6, 2020, 7:06pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/10 "2020-01-06T19:06:14Z")

</div>

A community memeber already started with it and I will try to finish it soon.

---

<div class="post-metadata">

**Author:** ![svenjanssen](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/svenjanssen/32/47634_2.png) [@svenjanssen](https://community.n8n.io/u/svenjanssen)\
**Post date:** [January 17, 2020, 12:53pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/11 "2020-01-17T12:53:34Z")

</div>

Cool, I’m definitly exited for it. SuiteCRM and Wazo integrations depend on it

---

<div class="post-metadata">

**Author:** ![svenjanssen](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/svenjanssen/32/47634_2.png) [@svenjanssen](https://community.n8n.io/u/svenjanssen)\
**Post date:** [January 29, 2020, 12:30pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/12 "2020-01-29T12:30:44Z")

</div>

Amazing, I see WIP (work in progress). Do you have a releasedate in mind already?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [January 29, 2020, 3:32pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/13 "2020-01-29T15:32:03Z")

</div>

No, sadly not. It depends really on how much time I find between all the other things I have to do right now. But is already quite close. So if I find a few hours of uninterrupted working time, it should be done.

---

<div class="post-metadata">

**Author:** ![svenjanssen](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/svenjanssen/32/47634_2.png) [@svenjanssen](https://community.n8n.io/u/svenjanssen)\
**Post date:** [February 6, 2020, 12:40pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/14 "2020-02-06T12:40:54Z")

</div>

Yes it’s hard to find uninterrupted working time without downright blocking it in the schedule. And I’m sure you have high standards for such important key functionality. I’ll just keep my fingers crossed 🤞 and follow up from time to time

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [February 9, 2020, 5:54am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/15 "2020-02-09T05:54:11Z")

</div>

The OAuth integration is now ready to be tested. It can be found in this branch:  
[https://github.com/n8n-io/n8n/tree/oauth-support](https://github.com/n8n-io/n8n/tree/oauth-support)

The HTTP-Request Node supports it and allows so testing with different services. Please give it a try and get back to me if you run into any problems. So I can then fix them before it gets merged into master and released.

---

<div class="post-metadata">

**Author:** ![tjenkins](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/tjenkins/32/360_2.png) [@tjenkins](https://community.n8n.io/u/tjenkins)\
**Post date:** [February 9, 2020, 11:42pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/16 "2020-02-09T23:42:41Z")

</div>

This is awesome, how can I run it on that branch?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [February 9, 2020, 11:48pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/17 "2020-02-09T23:48:01Z")

</div>

Works exactly the same as the code in “main” so you can check the guide here:

> <https://github.com/n8n-io/n8n/blob/master/CONTRIBUTING.md#actual-n8n-setup>

The only difference is that after stop 1 (the git clone) you execute this, to get the code of the branch which contains the oauth code:

```bash
git checkout oauth-support

```

The rest will then be identical.

---

<div class="post-metadata">

**Author:** ![sabatale](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sabatale/32/656_2.png) [@sabatale](https://community.n8n.io/u/sabatale)\
**Post date:** [February 20, 2020, 11:15pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/18 "2020-02-20T23:15:27Z")

</div>

Hello, thanks again!

I’m testing the oauth-support tree (shows up as version 44?) and am wondering what the reply URL (= redirect URI) should be? From what I see in the code, I was expecting something like **[https://www.xxx.come/rest/oauth2-credential/callback](https://www.xxx.come/rest/oauth2-credential/callback)**.

I get the idea from the following line in **Server.ts** : `redirectUri: ${WebhookHelpers.getWebhookBaseUrl()}rest/oauth2-credential/callback,`

However I get rejected by Microsoft OAuth 2.0 service despite having registered the above Reply URL on Azure:

> AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: {id}.

I may have missed something somewhere. Can you please confirm what the reply URL should be?

Thanks!

**EDIT:** Well, I quickly realized it makes sense [http://localhost:5678/rest/oauth2-credential/callback](http://localhost:5678/rest/oauth2-credential/callback) is the valid Reply URL… but then I get stuck because Azure can’t access localhost directly. For now, I’ve hardcoded my host in the Server.ts but being able to modify the host from the Editor-UI would be a plus.

**EDIT 2:** Although the connection is successful, I get the error “ERROR: Unexpected token o in JSON at position 1” when trying to get the token. I guess I’ll investigate more:

ERROR: Unexpected token o in JSON at position 1

```auto
SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at Object.execute (/home/xxx/n8n/packages/nodes-base/nodes/OAuth.node.ts:126:46)
    at Workflow.runNode (/home/xxx/n8n/packages/workflow/src/Workflow.ts:1147:28)
    at /home/xxx/n8n/packages/core/src/WorkflowExecute.ts:575:40

```

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [February 21, 2020, 6:47am UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/19 "2020-02-21T06:47:53Z")

</div>

Sorry, do not understand what you mean with “shows up as version 44?”.

There should be no need to hardcode any URL. Simply make sure that you have configured n8n correctly. In this case, n8n simply has to know how it can be reached. Here this one is important:

> **[Introduction | n8n Docs](https://docs.n8n.io/#/configuration?id=publish)**
>
> n8n is an extendable workflow automation tool that enables you to connect anything to everything via its open, fair-code model.

> **[Introduction | n8n Docs](https://docs.n8n.io/#/configuration?id=webhook-url)**
>
> n8n is an extendable workflow automation tool that enables you to connect anything to everything via its open, fair-code model.

About the `JSON.parse` problem you have. Do not use the OAuth-Node. It was just a simple test in the beginning to debug. Not sure if it is still functioning as quite a few changes have been made. To make an OAuth request, simply use the regular HTTP-Request Node. In the branch, it has OAuth support already built in.

I hope that helps.

---

<div class="post-metadata">

**Author:** ![sabatale](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sabatale/32/656_2.png) [@sabatale](https://community.n8n.io/u/sabatale)\
**Post date:** [February 21, 2020, 3:24pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/20 "2020-02-21T15:24:31Z")

</div>

I just noticed this was different from the master but it’s nothing I guess:

 ![044](https://europe1.discourse-cdn.com/n8n/original/1X/408d546fb010a4beb4ae9b3f1a4875408c82eddc.jpeg)

For the “hardcoding”, everything works fine with the hook and the publishing so I don’t expect any misconfiguration but I’ll double-check since it should work without having to change anything.

And OK, I hadn’t noticed the new option for HTTP requests… makes sense! I now get the following error: **ERROR: Unable to sign without access token** Can you confirm that the scope separator is a space?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [February 21, 2020, 3:53pm UTC](https://community.n8n.io/t/node-oauth2-api-got-created/189/21 "2020-02-21T15:53:06Z")

</div>

Yes, it should be a space. But do not know if that maybe differs with whomever you try to connect to.

The error message sounds like it did not receive an accessToken when you did the authentication. I would have expected that one always gets send no matter the scope but to have different access rights. So am surprised that it would be missing. The refresh token is, however, also normally only supplied if “offline” gets set so it is quite possible that it is “scope” related after all. Sadly no OAuth expert in any way. Sorry!

[Next page](https://community.n8n.io/t/node-oauth2-api-got-created/189.md?page=2)
