I would like to implement the TMDB authentication on my React App but I have some trouble after approving the request token.
TMDB authentication is done with 3 steps (more info here):
- Request a token (done)
- Get the token approved (this is the step I have issuses)
- Request session id (I can do the easily)
My problem is that to approve the token I need to open a new window, log in to my tmdb account and approve the token. After that I need to say to my React client that the token is approved and request the session id.
How can I wait until the token is approved and then request session id?
Here is my code :
// This function called when I dispatch login action with Redux
async function login(username, password) {
// Create a new request token
const token = await getToken()
// Get the user to authorize the request token
getUserPermission(token.request_token)
// --------------
// How do I wait for the user to approve the token and close the window and then request the session id
// --------------
// Create a new session_id with the athorized request token
const session = await getSession(token.request_token)
user.session_id = session.session_id
return user
}