-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Long Lived User Tokens #392
Changes from 3 commits
5bbfa0b
63a86ed
9c3b69d
a308d63
98420fa
05edd08
c37c485
ff920b6
938180a
2fa066a
228f6d0
91f090f
5acdfbb
cdabeb1
0ff19e5
f5be416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,6 +311,34 @@ def get_app_access_token(self, app_id, app_secret, offline=False): | |
return self.request("{0}/oauth/access_token".format(self.version), | ||
args=args)["access_token"] | ||
|
||
def get_long_lived_token(self, app_id, app_secret): | ||
""" | ||
Gets a long lived access token. | ||
This method uses a pre-existing short lived user access token and | ||
exchanges it for a long lived user access token. | ||
""" | ||
args = {'grant_type': 'fb_exchange_token', | ||
'client_id': app_id, | ||
'client_secret': app_secret, | ||
'fb_exchange_token': self.access_token} | ||
|
||
return self.request("{0}/oauth/access_token".format(self.version), | ||
args=args) | ||
|
||
def get_long_lived_token_code(self, app_id, app_secret, redirect_uri): | ||
""" | ||
Gets a code to be exchanged for a long lived token. | ||
Uses a pre-existing server side long lived token to return a code | ||
that can be redeemed for a client side long lived token. | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This docstring suffers from the same issues as the description in the documentation. |
||
args = {'access_token': self.access_token, | ||
'client_id': app_id, | ||
'client_secret': app_secret, | ||
'redirect_uri': redirect_uri} | ||
|
||
return self.request("{0}oauth/client_code".format(self.version), | ||
args=args)["code"] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a |
||
def get_access_token_from_code( | ||
self, code, redirect_uri, app_id, app_secret): | ||
"""Get an access token from the "code" returned from an OAuth dialog. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this exactly the same as the
extend_access_token
method?