Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authentication error while chunk upload of media. #99

Open
ankuratudemy opened this issue May 13, 2020 · 1 comment
Open

authentication error while chunk upload of media. #99

ankuratudemy opened this issue May 13, 2020 · 1 comment
Labels
question Further information is requested

Comments

@ankuratudemy
Copy link

ankuratudemy commented May 13, 2020

Hello,

I am trying to do chunk media upload for an Image. While my media/upload ( INIT) calls works fine, the next call for media/upload (APPEND) fails with authentication error:
{ errors: [ { code: 32, message: 'Could not authenticate you.' } ] }

I am using the same client object to make both the POST calls.

const appMediaConfig = {
    subdomain: 'upload',
    consumer_key: process.env.CONSUMER_KEY,
    consumer_secret: process.env.CONSUMER_SECRET,
    access_token_key: process.env.ACCESS_TOKEN,
    access_token_secret: process.env.ACCESS_TOKEN_SECRET,
    timeout_ms: 60 * 1000 // optional HTTP request timeout to apply to all requests.
  };

Here's my code:

//  THIS WORKS

function initMediaUpload(){
    return new Promise(async (resolve, reject) => {

    try{
      const result =  await twitterUpload.post("media/upload",{
        command: "INIT",
        media_type: "image/jpeg",
        total_bytes: WELCOME_IMAGE_SIZE,
        media_category: "dm_image"
     }
   )

   resolve(result);
    
   }
    catch (error) {
      // console.log("ERROR",error)
       reject(error);
     }
})
}

//  THIS FAILS
function appendMediaUpload(mediaid){
    return new Promise(async (resolve, reject) => {
    try{
      const result =  await twitterUpload.post("media/upload",{
        command: "APPEND",
        media_id: mediaid,
        media: WELCOME_IMAGE,
        segment_index: 0
     })
   resolve(result);
   }
    catch (error) {
       console.log("ERROR",error)
       reject(error);
     }})
}

I am just calling the INIT function , save the media_id_string , then call the APPEND function with captured media_id_string.

I have been banging my head on this for quite some time now. Maybe i am missing something or is there a bug ?? Any help will be great ..

Thank you :)

@rlueder rlueder added the question Further information is requested label Aug 10, 2021
@ishkapoor2000
Copy link

How to get the media_id_string via client.get(...) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

3 participants