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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:12:51+00:00 2026-06-14T22:12:51+00:00

I am using django’s social_auth for facebook authentication. I am trying to access the

  • 0

I am using django’s social_auth for facebook authentication. I am trying to access the token once a user is logged in using facebook so the app can do things like retrieve the user’s friends and what is on his/her newsfeed. However, I am having trouble getting that token. Below is what I have. {{instance}} displays in the template but when I add {{token}} I get an error saying ‘QuerySet’ object has no attribute ‘tokens’. How do I get the generated token?

view

def friends(request):   
    instance = UserSocialAuth.objects.filter(user=request.user).filter(provider='facebook') 
    token = instance.tokens
    return render_to_response('reserve/templates/friends.html', {'token':token, 'instance':instance},
        context_instance=RequestContext(request))

template

{{instance}}
<br>
{{token}}
  • 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-14T22:12:53+00:00Added an answer on June 14, 2026 at 10:12 pm

    The error says it all: a QuerySet is a collection of whatever your searched for (in this case, UserSocialAuth). To get a field in that model you need to iterate over the collection:

    tokens = [x.tokens for x in instance]
    

    As an alternative, if you’re sure your filter will return exactly one instance (not zero, not 2 or more) you can use get instead of filter:

    instance = UserSocialAuth.objects.get(user=request.user, provider='facebook') 
    token = instance.tokens
    

    Note however that a single provider can return more than one token, like oauth_token and oauth_token_secret, so you should select which one you want and/or format it appropriately.

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

Sidebar

Related Questions

Am using django social-auth authentication for my app.After login to facebook or twitter from
Using django-social-auth to grab user data from facebook, it is returning a list of
Using Django 1.1, I am trying to select the maximum value from a varchar
Using Django templates in Google App Engine (on Python), is it possible to compare
I am using django-haystack. In the highlight haystack provides, how can i render tags
I am using Django 1.3 and python 2.7 .I am using Django admin app.What
Using django, I'm trying to get a QuerySet of FK relationships from another QuerySet.
using django 1.4, I am trying to Post and it seems like its not
Am using django-registration for user account activation. in my registration_form.html I have {% extends
I am using django-nonrel on the google-app-engine. When I'm posting a foreign character, in

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.