Solved

CData REST provider using API key

  • 7 October 2022
  • 9 replies
  • 310 views

We have a new REST API data source that we are trying to connect to.  This data source takes only an API key through the Authorization: Bearer <api_token> request header.  I am using the CData ADO.NET Provider for REST 2019.  I have added the API URI and the custom header (bearer token), and even selected OAuth 2.0 and added a Callback URL of http://localhost:33333.  No matter what I do, it seems as though the API key is not being passed correctly.  The message I get in the response is "{"message":"Invalid Token"}" and "HTTP/1.1 401 Unauthorized".  I am able to connect to this data source using Postman with the Authorization: Bearer token.  Can anyone give advise on specific settings for using only an API key?

Thanks,

Dan

icon

Best answer by dan.beggs 12 October 2022, 15:39

View original

9 replies

Userlevel 5
Badge +5

Hi Daniel

The following worked for me.
XRj-VLJYXAFeUQwoZi8vXw.png

As you may notice the difference between what you suggest and my setup is the blank space between Authorization: Bearer
which I do not have. This field requires a very specific setup to work.

Userlevel 5
Badge +5

So due to this, I also mention this in my guide.

https://legacysupport.timextender.com/hc/en-us/articles/360034695651-Connect-to-a-REST-API#using-a-custom-header

Hello Thomas.  Thanks for the response.  The guide you linked is one that I have been referencing.  I had actually tried it both ways, with and without a space between "Authorization:" and "Bearer", with no difference.  What settings do you have under the OAuth section when you have this working?

Thanks

Hello.  I am still struggling with this.  It works fine in Postman.  I have copied and pasted the Bearer token into TimeXtender, so I know it is not an issue with a wrong token.  If I set OAuth Version to Disabled, I get this error: "HTTP/1.1 406 Not Acceptable".  If I set OAuth Version to 1.0 or 2.0, I get these errors: {"message":"Invalid Token"} and "HTTP/1.1 401 Unauthorized".  If I use an obviously wrong token, I still get the same "Invalid Token" error.  It seems like it is not passing the token correctly, but I do not know what else to try to change to correct the issue.

Userlevel 5
Badge +5

When you use a custom header like a bearer token. That is the only option you need to use. So the Auth field is set to none and the OAuth as well.
Like in the two following images of my setup.7YmDK3K5VbVnUYgLpaJUIw.png

 

35gTfERlhgz3XQTZTKLngA.png

The version of TimeXtender we are using is 20.5.5, so my options are slightly different.  When I make what I think are the same settings as you, I get the "HTTP/1.1 406 Not Acceptable" error.

Here are my settings:

6f6WkHPI2thhlLTjdns4Yw.png

NjFHC85E4exfgdN0GBlpgw.png

-GKuv8SeFHDMJLyRVwmWdA.png

 

Userlevel 5
Badge +5

It is an error related to a missing accept header.
It may be due to the age of the provider, but you can probably add it manually. What type it is missing I do not know, but using postman or another tool you can see what headers it uses.

Ok, I will look into that.  Thank you.

That was it.  I just had to pass the Accept:*/* header and then it worked.  Thank you for your assistance.

Reply