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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:55:31+00:00 2026-06-12T02:55:31+00:00

I am using facepy facebook graph API to access my mailbox/messages and I followed

  • 0

I am using facepy facebook graph API to access my mailbox/messages and I followed the following two approaches:

1st Approach:

I used the access token I got from Graph Explorer facebook page and use the below code:

from facepy import GraphAPI
graph = GraphAPI(token)
print graph.get('/me')
#Rest of the code

The above code worked fine and I was able to retrieve all my messages using an FQL Query. The problem arised when my auth_token expired after sometime.

So, after some googling I shifted to approach two:

Now, what I did was created a facebook app gave it read_mailbox permission and got it’s id and key and then used get_application_access_token method of facepy to get the token.

After retrieving the token I used:

token = facepy.utils.get_application_access_token(app_id, key)
graph.get('/me')
## OUT: OAuthError: [2500] An active access token must be used to query information about the current user.
facepy.utils.get_extended_access_token(token, app_id, key)
# OUT: OAuthError: [1] No user access token specified

Now, you can see the error(commented #) generated on using the application token.

I believe the error I am getting is because facebook needs the user_token and I am supplying it with app_token.

So, is it possible to access user data using the app_token and if not how can one issue a extended token which can access user data.

Update:

So, I followed @Johannes suggestion and tried this but ran into error:

from facepy.utils import get_extended_access_token
from facepy import GraphAPI
token = "My user access token got from https://developers.facebook.com/tools/explorer"
long_lived_access_token = get_extended_access_token(token)
graph = GraphAPI(long_lived_access_token)
graph.get('/me')

Now, when I ran the above code I got

TypeError: get_extended_access_token() takes exactly 3 arguments (1 given)

So, I changed it to long_lived_access_token = get_extended_access_token(token, None, None) and got

facepy.exceptions.OAuthError

So, I again I changed it to long_lived_access_token = get_extended_access_token(token, app_id, key) and I got the same exception/error as above.

So, is this a bug or am I doing something wrong.

PS: I installed the latest version from git.

  • 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-12T02:55:32+00:00Added an answer on June 12, 2026 at 2:55 am

    You’re right in your assumption that you cannot use application access tokens to read a user’s mailbox, but the error you’re getting stems from the fact that you haven’t initialized graph with an access token at all.

    Be that as it may, you’re on the right track in asking for how you can extend the user’s access token. As you have already discovered, Facepy HEAD (soon to be version 0.9) has a function get_extended_access_token which accepts an existing short-lived user access token and extends it. Extended user access tokens last for 2 months, and you can read more about them in Facebook’s documentation on the removal of offline_access permission.

    If you want to use get_extended_access_token right now, you will have to install facepy from git:

    $ pip install git+git://github.com/jgorset/facepy.git@b5153f460f2f52cef9a5e49a3b48b3fb8742356c
    

    Once you’ve installed the right version of Facepy, you can extend an existing short-lived user access token and initialize a new instance of GraphAPI with it:

    from facepy.utils import get_extended_access_token
    from facepy import GraphAPI
    
    long_lived_access_token, expires_at = get_extended_access_token(short_lived_access_token, application_id, application_secret_key)
    
    graph = GraphAPI(long_lived_access_token)
    graph.get('/me')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using facepy facebook api to fetch messages from my facebook account. I
Using the new mvc4 now gives us access to use facebook oauth otb. I
I am using fandjango and facepy for building facebook application. So, this is how
Using WPF/PRISM I want to log my messages through ILoggerFacade to my GUI (A
Using the HTML5 File API I can get the Binary String representation of a
Using MySQL for basic storage of system/user data. I need to store/search messages (adding
I am thinking to implement Facebook Wordpress Plugin for bloggers in django (using Fandjango
Using C#, I want to show the image in the Access column but failed
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using SLComposeViewController , I notice curious behavior when posting to Facebook if both 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.