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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:49:23+00:00 2026-06-15T00:49:23+00:00

I have an oauth flow in which a user grants access to a certain

  • 0

I have an oauth flow in which a user grants access to a certain scope and then my application can do stuff. For this to work, I need an access token with the defined scope.
I implemented this (with the django allauth package) and it works great. But…
I would like to test it.
This is what I have so far (request package is like an urllib on steroids):

    login = self.client.login(username='test_user', password='test')
    self.assertTrue(login)

    resp = self.client.post(reverse('oauth_login'))
    self.assertEqual(resp.status_code, 302)

    payload = {'session_key': 'email', 'session_password': 'pw', }

    resp2 = requests.post(resp['location'], data=payload)

    resp3 = self.client.get(reverse('do_stuff_with_access_token'))
    self.assertEqual(resp.status_code, 302)

The issue here is that I do not get the access token in my request variables. My guess is that I am going out of the scope of the application and Django does not get the variable in its request scope.

How can you test this in an elegant manner? Mocking an access_token seems a bit wrong to me. I am now trying to go Selenium for filling in the form, but even that is not really a success so far…

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-06-15T00:49:24+00:00Added an answer on June 15, 2026 at 12:49 am

    Kudos to Mark!

    To help anyone on their way.
    Mocking worked out. In my case (django 1.4) you need to add your tokens to the session. A lot of different advices can be found on the net, but I like simple things and this works in Django at least with the test suite:

    session = self.client.session
    session['request_token'] = {...}
    session['access_token'] = {...}
    session.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a user's table which contains a one-to-one relationship for Youtube OAuth
I have an application that integrates with Facebook using Oauth 2. I can authorize
I am developing a Facebook app. I have a server side OAuth flow which
I have just succeeded in creating oAuth authentication for my twitter application using PHP.
we need to Login Facebook,Twitter,Gmail from our desktop application we have OAuth tokens such
i have used oauth mechanism to let the user login via twitter in my
I am building an Android application that requires OAuth. I have all the OAuth
I'm working with the OAuth 2.0 for MVC which can be found here: http://community.codesmithtools.com/CodeSmith_Community/b/tdupont/archive/2011/03/18/oauth-2-0-for-mvc-two-legged-implementation.aspx#comments
I'm trying to create a Webapp which can read the user's Dropbox files. If
In the three legged flow you have a callbackAuthorize which would allow you to

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.