1

Currently am using Graph Explorer to get a short-lived user access token and than converting it to a extended token(60 days) by a call to facepy get_extended_access_token method.

Now. consider the scenario where my user access token becomes invalid because of either user logging out or the token expires itself. So, in both the cases I need to get a new user access token because get_extended_access_token requires access_token so that it can extend it.

So, my question is how to retrieve this token using python? Is there any particular url which I can send a request and it will return a new/updated token in resonse.

Update:

So, after following this post and making a request to

https://graph.facebook.com/oauth/access_token?client_id=xxxx&client_secret=yyyy&grant_type=client_credentials

I got this token which I believe is an app access token

access_token=123456789|12abcdef234 #changed from original

But what I need is an user access token through which I can read my mailbox.

1

1 Answer 1

1

If the access token has expired or been invalidated you need to go back through the Auth Dialog, i.e. a user must manually re-grant access to your application. Retrieving it programmatically defeats the whole purpose of token invalidation/expiry.

Once you get this token, you can then use get_extended_access_token to get the long lived one

App tokens can be used to publish a post on the user's behalf.

Sign up to request clarification or add additional context in comments.

4 Comments

Sorry for sounding noobish but what exactly do you mean by go back through the Auth Dialog because currently what I am doing is get an access token from graph explorer than use get_extended_access_token to get a new token and using that token run a FQL query. So, you can see no where there is need to grant access to the application. The only reason I had to create an application is to app id and secret to get a extended token.
@Noob no it cannot be used for that. Auth Dialog can be invoked via facebook.com/dialog/… which is what the Graph API Explorer sends you every time you add a new permission in the tool
So, on using the above url with redirect_uri=https://www.facebook.com/connect/login_success.html I get a success page having a valid user token in the page url. Now, is the above procedure possible using python because I believe one has to be logged in on facebook to do that.
SO, the solution I came up for this is invoke the browser with the above url and ask the user to copy the access_token and paste it in a config file.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.