Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: Unauthorized access when using API token in n8n node #7084

Closed
1 task done
samjaninf opened this issue Nov 24, 2023 · 21 comments · Fixed by #7083 or #7213
Closed
1 task done

🐛 Bug: Unauthorized access when using API token in n8n node #7084

samjaninf opened this issue Nov 24, 2023 · 21 comments · Fixed by #7083 or #7213
Assignees
Labels

Comments

@samjaninf
Copy link

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Steps to reproduce ?

Using n8n, set the NocoDB node to the v0.200.0 Onwards and set up a NocoDB API Token credential.

Then try to connect to an updated nocodb instance.

Desired Behavior

I should be able to list Tables and CRUD on any Bases/Projects in the NocoDB instance.

I am aware a few other bugs existed with similar issues but this problem still exists for me.

#5713
#6328

When I use the API Token credential it allows me to read the Base/Projects, but not the Tables, and I get Unauthorized Access when I try to run the node. Same exact issue as with #6328 .

It works with the User Auth Token but I can't get the NC_JWT_EXPIRES_IN environment variable to work properly either, It seems to still expire in 10 hours but doesn't create a new one if this envar is set. So it just gets stuck in limbo.

Project Details

Node: **v18.17.1**
Arch: **x64**
Platform: **linux**
Docker: **true**
RootDB: **pg**
PackageVersion: **0.202.8**

Attachments

No response

@mertmit
Copy link
Member

mertmit commented Nov 24, 2023

Hey @samjaninf, thank you for reporting, this should be fixed by #7083
You can wait for next release or try our PR build immediately docker run -d -p 8888:8080 nocodb/nocodb-timely:0.202.8-pr-7083-20231124-1008
Let me know if you give it a try 🙌

@VictorDelCampo
Copy link

@mertmit
After updating from 0.111.4 to the latest version 0.202.9 we realised that the API token access is not working anymore. We get on every table access a HTTP 403 with the response:

{
    "msg": "Unauthorized access"
}

We tested the access with a JWT token and it work.s Even created a new API token but same 403 result.

Is this issue really solved?

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

Hi @VictorDelCampo,
Which API are you trying to access?

@VictorDelCampo
Copy link

We are trying to access the API of our internal nocodb instance. Both v1 and v2 do not accept the API token

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

I mean is it for all endpoints, because right now I am confirming with data endpoints and it is working.
If you have an example failing endpoint that would be great

@VictorDelCampo
Copy link

Oh sorry!

  • /api/v1/db/data/v1/XXXX
  • /api/v2/tables/md_06l2wnshobrh6o/records

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

For example:

curl --location 'http://localhost:8080/api/v2/tables/mz9sq4oplihwnbg/records' \
--header 'xc-token: C5cd_YzQFVzCCzNii_KcSe_eXuKIlA2NXGShxPK0' \

this example request works on my local tests for v0.202.9
can you try replacing your token and table id, or can you see is there something different?

@VictorDelCampo
Copy link

I created a new API token and tried our any other table and same problem.
JWT token is working properly.

This is our project info:
Node: v18.17.1
Arch: x64
Platform: linux
Docker: true
RootDB: pg
PackageVersion: 0.202.9

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

if you are trying with n8n can you confirm you are selecting API Token for credentials and not User Token
image

@VictorDelCampo
Copy link

We are creating it through nocodb:
image

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

I would like to confirm you are providing header as xc-token not xc-auth as xc-auth only works with user token whereas xc-token works with API Token.

@VictorDelCampo
Copy link

Yes we are using xc-token for the header, when using the API key

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

Can you confirm what is the role of the user that token belongs to? (Org Role and Base Role)

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

@VictorDelCampo thank you for reporting this, I've find a typo which leads to this, created a fix PR.
This should fix your issue. PR Build will be available soon (actions takes 25~mins), I will ping it here, it would be great help if you can confirm on your side.

@VictorDelCampo
Copy link

Awesome finding. Thanks for the quick support. I will confirm on my side once the bug fix is done and you ping here

@mertmit
Copy link
Member

mertmit commented Dec 12, 2023

Here is the PR build: docker run -d -p 8888:8080 nocodb/nocodb-timely:0.202.9-pr-7213-20231212-1405

@VictorDelCampo
Copy link

Are you planning on creating a new release with the bug fix? I guess other users are also affected and would need the bug fix

@Petrogrado1917
Copy link

You guess right. I'm also affected and blocked. Please, guys, bug this fix. Thanks in advance

@mertmit
Copy link
Member

mertmit commented Dec 14, 2023

@Petrogrado1917 our latest bugfix release should work for you, are you still having problem https://github.com/nocodb/nocodb/releases/tag/0.202.10

@Petrogrado1917
Copy link

Petrogrado1917 commented Dec 14, 2023 via email

@Petrogrado1917
Copy link

Petrogrado1917 commented Dec 15, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants