Having "disconnection" problem with OAuth2 every day

Hi!
I’m having a problem where a OAuth2 connection with RD Station “disconnects” every day or so. It doesnt really show as disconnected, but instead only works as if wasn’t connected(error 400 and not null erros about authentication). When I force it to reconnect, it starts to working again

I’m getting a error 400 with “body_client_id” cannot be null(the OAuth2 connection is properly done i think)

Information on your n8n setup

  • **n8n version: Version 0.210.0 **
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: npm

Hi @Gabriel_Zara, welcome to the community and sorry for the trouble you are having.

I am not familiar with RD Station nor do I know how your credentials are configured I am afraid. But just based on the error they are returning, is there a chance you simply need to send the credentials in the request body instead of the header? This is an option at the very bottom of the OAuth2 credentials screen:

Hey @MutedJam , thanks!

I’m passing my credentials in body. I figured out that the problem seems to be that my token isn’t auto refreshing, as it should

When I configure the OAuth2 first time, works fine for like 24hrs, then it disconnects. Not sure if this is a problem related to RD Station specifically or if it could be something else, but it is really annoying to not get auto refreshing on the token. Any idea of what could it be? Or could be a case where the authentication on the RD is lacking something and I would be forced to do some kind of “manual” process on Oauth2 refresh token?

Hey @Gabriel_Zara,

Sometimes an offline_access scope needs to be passed, Does RD Station expect the same thing?

Hey @Jon ,
I asked the RD Station support team about that, and they replied me saying that there isn’t any scopes or similar things(and the documentation does not have anything about that too)

Hey @Gabriel_Zara,

Do they believe the refresh should be working? Does RD Station have any logs maybe that could show what is happening?

Hey @Jon

Yea, I just opened another ticket with them and they don’t get what is wrong or something like that. I can’t get access to any logs too.

I’ll prob setup a “manual” way to do the refreshes every 12 hours or so, or something like that. Just to be sure, once I properly configure the OAuth2 connection inside n8n, the refreshes should be working as well, right?
im kinda new to n8n, but i’m used to other integration platforms and usually works this way. I hadnt any other problems with authentication/refreshing tokens besides that

Also, I just read something in another forum post about “Oauth2 authentication” that was said that the refreshes happen when the request returns “401 unauthorized”. But the RD Station does not returns that when the token expires, it just returns 400 like above

could this be the issue? is possible to fix this if is the case?

So yeah the refresh should happen automatically, I have just taken a look and we do a refresh if the token has expired or if the services returns a 401 code which is the HTTP standard for ‘unauthorized’. We could maybe look at adding 400 in the future but my worry there is a 400 error is a generic error and could be for anything so it could cause problems for other services.

The API docs for RD Station seem to suggest they will throw a 401 error though so it should be working, It could be that the 400 is being returned because something else is wrong with the settings it is hard to say. I am not sure why it would say body_client_id is null as they don’t specify that as an option on their docs page :thinking:

Hey @Jon

Going into further testing with this case and using Beeceptor to see what was happening in the request when it “disconnects” I noticed that the authentication token is being passed on header, but in the Oauth2 setting is configured to be on body. No idea if those two things are related but maybe the error 400 is being throw because it expects the ids/tokens to do the refresh in body

This is what beeceptor receive when I tried to reach it with the OAuth2 “disconnected”:

"--request GET \
--url https://testen8n123.free.beeceptor.com/my/api/path \
--header 'host: testen8n123.free.beeceptor.com' \
--header 'user-agent: axios/0.21.4' \
--header 'accept: application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7' \
--header 'authorization: Bearer IvYXBpL3YyLyIsImFwcF9uYW1lIjoiSW50ZWdyYcOnw7VlcyBGbGV4eSAtIEJpdHJpeDI0ICIsImV4cCI6MTY3NjU1MjkyOCwiaWF0IjoxNjc2NDY2NTI4LCJzY29wZSI6IiJ9.QNkz-jDOMKT4_IwOfK7xkA6dEzpK6pNNNgh4Q4t9gsPl56eQ' \
--header 'x-forwarded-for: 54.227.41.88' \
--header 'x-forwarded-host: testen8n123.free.beeceptor.com' \
--header 'x-forwarded-proto: https' \
--header 'x-real-ip: 54.227.41.88' \
--header 'accept-encoding: gzip'"

(the token is not working no worries)

I will need to check but I would have expected it to be sent in the body if that is what you have set :thinking:

yea

Sending auth in body. I’m thinking that it requires to be in body to get a 401 error, but i think ill havbe to wait until tomorrow(to get the disconnection) to be able to test it

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