The Movie Database 支持

Hi, I'm trying to create a list via "Try it" feature on the API reference page. However, I'm failing with 401 saying: 'Sorry, your couldn't be authenticated with those credentials' pointing at my access token.

My fetch request:

const url = 'https://api.themoviedb.org/3/list?session_id=%7B%20%20%20%22success%22%3A%20true%2C%20%20%20%22session_id%22%3A%20%2230036ee8426fc0d347056e7be55fb77565598114%22%20%7D';
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    Authorization: 'Bearer {MY_ACCESS_TOKEN}'
  },
  body: JSON.stringify({name: 'SUH first list', description: 'This is my first list', language: 'en'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));

Response:

{
  "success": false,
  "status_code": 3,
  "status_message": "Authentication failed: You do not have permissions to access the service."
}

I'm new to the Authentication API. I've created the request_token, authorized it and created a session_id successfully. However, when I try to create a list on a test basis, I fail as mentioned above.

Kindly let me know what I'm doing wrong.

Thanks!

4 回复(第 1 页,共 1 页)

Jump to last post

It's because you're authenticating with a bearer token. That is taking preference over your query params.

If you want to keep using a bearer token, you will need to create an access token that has been authorized by your user. This is outlined here.

If you don't care about bearer authentication, switch to using api_key as a query param, and delete the Authorization header.

I didn't quite get it. Firstly, I forgot to explicitly mention that I was using V3, although it was evident from the fetch request I shared.

So if I wanna keep using the bearer token, I'll have to switch to using V4 way of authorization via an access token?

The bearer token is already technically “v4” authentication. That’s why you’re having an issue.

So yes, you have to continue to use v4 for user authentication, or switch to query params for authentication (which is technically “v3”).

For anyone interested in the outcome of this thread:

If someone wants to keep using the bearer token in V3, he should create an access_token using this V4 workflow.

Then, use this access_token to get a session_id in V3 as mentioned here.

找不到电影或节目?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)上一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区