Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:35:23+00:00 2026-05-31T22:35:23+00:00

So I’m new to OAuth and Node.JS, but I have to create a Flickr

  • 0

So I’m new to OAuth and Node.JS, but I have to create a Flickr bot to upload photos for a university project. From my understanding Node doesn’t have native support of multipart/formdata requests so I constructed the POST request manually.

I know the following code isn’t necessarily clean or best-practice, but it’s meant to be a one-off hack: the server is being requested by a single computer and only running for a few hours.

this.post = function(text, image) {
    var me = this;  
    if (me.authenticated) {
        fs.readFile(image, 'utf8', function(err,data) {
            if (err) throw new Error(err);                  
            var bound = (crypto.createHash('md5').update((Math.random()*9999999).toString()).digest('hex'));
            var req = http.request({host:'api.flickr.com',port:80,path:'/services/upload/',method:'POST',
                headers:{
                    'Content-Type':'multipart/form-data; boundary='+bound,
                    'Content-Length':data.length,
                    'Connection':'keep-alive'
                }
            }, function(res) {
                res.setEncoding('utf8');
                res.on('data', function(chunk) {
                    console.log(chunk);
                });
                console.log(me);
            });

            bound = "--"+bound;
            req.on('error', function(msg) {console.log('FLICKR UPLOAD ERROR: '+msg.message);});

            req.write(bound+"\r\n");
            req.write('Content-Disposition: form-data; name="api_key"\r\n\r\n'+flickroptions.key);
            req.write("\r\n"+bound+"\r\n");
            console.log("sending token "+me.token);
            req.write('Content-Disposition: form-data; name="auth_token"\r\n\r\n'+me.token);
            req.write("\r\n"+bound+"\r\n");
            req.write('Content-Disposition: form-data; name="api_sig"\r\n\r\n'+function() {
                var str = 'api_key'+flickroptions.key;
                str += 'api_token'+me.token;
                return crypto.createHash('md5').update(str).digest('hex');
            }());
            req.write("\r\n"+bound+"\r\n");
            req.write('Content-Disposition: form-data; name="photo"; filename="'+image+'"\r\n');
            req.write('Content-Type: image/jpeg\r\n\r\n');
            req.write(data);
            req.write('\r\n'+bound+"--"); req.end();
        });
    }
}

The above function generates a POST request more or less the same as recommended in the documentation. But for some reason, the request responds saying that auth_token is invalid.

I’m setting up authentication with the following two functions:

this.init = function(text,image) {
    var me = this;
    fauth.getOAuthRequestToken({'oauth_callback':'http://192.168.0.19:7001/flickr'}, function(err, token, secret, results) {
        if (err) console.log(err);      
        if (token && secret) {
            me.secret = secret; me.token = token;
            me.location = 'http://flicker.com/services/oauth/authorize?perms=write&oauth_token='+token;
        }
    });     
}

//?oauth_token&oauth_verifier
this.auth = function(token, verifier) {
    var me = this;
    this.token = token; this.verifier = verifier;
    fauth.getOAuthAccessToken(this.token, this.secret, this.verifier, function(err,token,secret,results) {
        if (err) {console.log(err); return;}
        me.results = results; me.authenticated = true;
        me.token = token;
        me.secret = secret;
        me.post('hello world', '../eyes/memory/eyes000001.jpg');
    });
}

Where this.init gets a Flickr authentication page and this.auth processes the redirected callback and then calls this.post. fauth is an instance of node-oauth. Am I missing a step in the process or have I messed up along the way? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:35:24+00:00Added an answer on May 31, 2026 at 10:35 pm

    When using OAuth you no longer us the api_key, api_sig and auth_token parameters anymore, even for uploading. You should be using oauth_consumer_key, oauth_signature and oauth_token instead.

    An OAuth Token is not a valid old style auth_token, and vice versa.

    Check out my blog series on Flickr and OAuth for more details: http://www.wackylabs.net/2011/12/oauth-and-flickr-part-1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.