Whats the status of the API, authentication?

A place for developers to advertise their TheTVDB.com enabled app and get help from other developers with the API.
Post Reply
kurick
Posts: 10
Joined: Fri May 01, 2015 6:36 am

Tue Nov 19, 2019 5:36 pm

This is an off and on again part time project me, so I am not always up today with the status of this API, so I am just trying to get caught up.

I just recently came back to working on it, and after a few days of issues I scoured the forum tonight, read many post about issue with the API (particularly v3) lately but was unable to find an answer to my problem.

Why can't I authenticate and get a token via a tool like Postman, but I can on the API documentation page, https://api.thetvdb.com/swagger?
Postman result:

Code: Select all

{
    "Error": "Not authorized"
}
I am using the exact same APIKEY, USERKEY and USERNAME.

Questions/comments:
Do I need to use all three attributes? The API documentation site works with all three, but a recent post listing outstanding issues and bug fixes say only the APIKEY is needed. I tired using all three and the just API key, still Error:Not Authorized.

What version is the current default of the API? The API documentation page list 3.0.0 at the top, then v2 right below it?

What URL should be used to access the endpoint? I have tried https://api.thetvdb.com/, https://api-dev.thetvdb.com/, https://api-beta.thetvdb.com/, they all respond but still give me Error: Not Authorized.

Did the USERKEY's change? If so why, and how would we be made aware of it? I had a USERKEY previously but when I stared having this trouble recently I looked into my account and my USERKEY was different than what I previously had. I tried the new one and that doesn't work either.
kurick
Posts: 10
Joined: Fri May 01, 2015 6:36 am

Fri Nov 22, 2019 11:47 am

Can anyone point me in the right direction please? Why can I authenticate on the Swagger site, but no via a tool like Postman?
k_zeon
Posts: 73
Joined: Mon Nov 23, 2015 10:17 am

Fri Nov 22, 2019 12:43 pm

as far as i know , just use the apikey. take out the username & userkey
{"apikey":"xxxxxxxxxxxxxxx","username":"","userkey":""}
/\ /\
blank blank
niallobr
Posts: 5
Joined: Sat Nov 23, 2019 7:50 am

Sat Nov 23, 2019 8:13 am

kurick wrote:
Fri Nov 22, 2019 11:47 am
Can anyone point me in the right direction please? Why can I authenticate on the Swagger site, but no via a tool like Postman?
Did you find a solution kurick? I'm also stuck...

I can also retrieve my token successfully on the https://api.thetvdb.com/swagger page, but not in the application I'm testing.

I've connected to the Trakt and Fanart.tv API using the .fetch method, but I'm struggling with TheTVDB.

Because of CORS issues, I'm using a local proxy to forward requests to https://api.thetvdb.com. I've tested this elsewhere and it usually works fine. I'm also getting a normal response from the server, which is the rejection. See below.

Request

Code: Select all

fetch('http://localhost:8011/proxy' + '/login', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  data: {
    'apikey': 'XXXXXX',
    'userkey': 'XXXXXX',
    'username': 'XXXXXX',
  },
})
    .then((response) => response.json())
    .then((data) => {
      console.log(data);
    })
    .catch((error) => console.error(error));
Response

Code: Select all

Failed to load resource: the server responded with a status of 401 (Unauthorized)
{Error: "Not authorized"}
Could it be some problem with encoding? I've also tried with just the API Key on its own etc... I'm a bit lost so would appreciate any help!
komo
Posts: 2
Joined: Sat Nov 23, 2019 11:19 am

Sat Nov 23, 2019 11:21 am

Having the same problem. Was anyone able to resolve this?
komo
Posts: 2
Joined: Sat Nov 23, 2019 11:19 am

Sat Nov 23, 2019 2:13 pm

Figured it out. The credentials key :value string (apikey, etc) goes into the request body. Not the header.
niallobr
Posts: 5
Joined: Sat Nov 23, 2019 7:50 am

Sat Nov 23, 2019 4:18 pm

Thanks for the tip ;)

Also had to JSON.stringify it inside the body, in case it helps somebody.

Now I have the key: value token response.
kurick
Posts: 10
Joined: Fri May 01, 2015 6:36 am

Mon Nov 25, 2019 5:11 am

komo wrote:
Sat Nov 23, 2019 2:13 pm
Figured it out. The credentials key :value string (apikey, etc) goes into the request body. Not the header.
Thanks for the tip! I wish the documentation was updated to make this more clear.

If any one is using the tool Postman for testing the API, I'll give some further insight into what I had to do:
  • Under the headers section I had to set the key:value pair to Content-Type:application/json
  • I then had to set the body section to Raw and use the apikey:value pair like this:

    Code: Select all

    {
      "apikey": "XXXXXXXXXXXXXX"
    }
Post Reply