mirror of
https://github.com/Viren070/tmdb-addon.git
synced 2025-12-01 23:18:11 +01:00
25 lines
896 B
JavaScript
25 lines
896 B
JavaScript
require("dotenv").config();
|
|
const axios = require("axios")
|
|
const { MovieDb } = require("moviedb-promise");
|
|
const moviedb = new MovieDb(process.env.TMDB_API);
|
|
moviedb.sessionId = '051e2865c49c81d4c010d1506d9adaef033b2e65'
|
|
|
|
async function getRequestToken() {
|
|
return axios.get(`https://api.themoviedb.org/3/authentication/token/new?api_key=${process.env.TMDB_API}`)
|
|
.then(response => {
|
|
if (response.data.success) {
|
|
return response.data.request_token
|
|
}
|
|
})
|
|
}
|
|
|
|
async function getSessionId(requestToken) {
|
|
return axios.get(`https://api.themoviedb.org/3/authentication/session/new?api_key=${process.env.TMDB_API}&request_token=${requestToken}`)
|
|
.then(response => {
|
|
if (response.data.success) {
|
|
return response.data.session_id
|
|
}
|
|
})
|
|
}
|
|
|
|
module.exports = { getRequestToken, getSessionId } |