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 7961553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:04:25+00:00 2026-06-04T05:04:25+00:00

I’m new to using any API, as well as HTTP requests, so I’m having

  • 0

I’m new to using any API, as well as HTTP requests, so I’m having some trouble. I’m not sure how to pass token information to the API, after I get it from a GET request. The imgur API says it needs the three endpoints: http://api.imgur.com/auth but I only get as far as the second one, because I’m not able to pass the requested tokens in.

The modules documentation is awfully vague to me about it: https://github.com/maraujop/requests-oauth

Here’s the code I’ve written that is supposed to pass authentication successfully, but it returns an html page http://pastebin.com/19hnBy1C.

import requests
from oauth_hook import OAuthHook
import cgi

OAuthHook.consumer_key = 'XXXXXXX'
OAuthHook.consumer_secret = 'YYYYY'


#just in case
oauth_hook = OAuthHook(header_auth=True)

#request the tokens, using the keys set above
r = requests.get(url='https://api.imgur.com/oauth/request_token', hooks={'pre_request': oauth_hook,})

#parse the lsit
tokenList = cgi.parse_qs(r.content)

token = tokenList['oauth_token']
tokenSecret = tokenList['oauth_token_secret']

#this is where I'm not sure what to do, 
#I create a new hook with the tokens I received
oauth_hook = OAuthHook(access_token=token[0], access_token_secret=tokenSecret[0])

#send the GET request
r = requests.get(url='https://api.imgur.com/oauth/authorize', hooks={'pre_request': oauth_hook,})

#this is that HTML that requires me to enter account info, how do I do that in python?
print r.content

#this is the next step, which, if you uncomment the last print, shows that the auth failed.
r = requests.get(url='https://api.imgur.com/oauth/access_token', hooks={'pre_request': oauth_hook,})

#print r.text

What is the best way to continue?

I thought maybe that I could send a POST to the authorize api, with my username/password as a data or a parameter, but that didn’t seem to work.

The Imgur API suggests I look at some twitter docs to get a good idea, but the one I’m reading: http://net.tutsplus.com/tutorials/php/how-to-authenticate-users-with-twitter-oauth/ , is a bit over my head, since it’s PHP, though it seems like it is what I should be doing.

  • 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-06-04T05:04:26+00:00Added an answer on June 4, 2026 at 5:04 am

    I’m the author of requests-oauth. I’ve recently released version 0.4.0 of this app and improved docs for helping new comers to OAuth.

    Here, hopefully, is the answer to your question:
    https://github.com/maraujop/requests-oauth#3-legged-authorization

    Sorry to take so long to answer.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.