Created
May 13, 2011 04:34
-
-
Save smalyshev/969975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import urlparse | |
| import oauth2 as oauth | |
| import urllib | |
| consumer_key = 'CONSUMERKEY' | |
| consumer_secret = 'CONSUMERSECRET' | |
| url = 'http://localhost:8888/sugar63/service/v4/rest.php' | |
| restparams = { | |
| 'input_type': 'json', | |
| 'request_type': 'json', | |
| 'method':'', | |
| } | |
| consumer = oauth.Consumer(consumer_key, consumer_secret) | |
| client = oauth.Client(consumer) | |
| # Step 1: Get a request token. This is a temporary token that is used for | |
| # having the user authorize an access token and to sign the request to obtain | |
| # said access token. | |
| restparams['method'] = 'oauth_request_token' | |
| resp, content = client.request(url, "POST", body=urllib.urlencode(restparams)) | |
| if resp['status'] != '200': | |
| print resp | |
| print content | |
| raise Exception("Invalid response %s." % resp['status']) | |
| request_token = dict(urlparse.parse_qsl(content)) | |
| print "Request Token:" | |
| print " - oauth_token = %s" % request_token['oauth_token'] | |
| print " - oauth_token_secret = %s" % request_token['oauth_token_secret'] | |
| authorize_url = request_token['authorize_url'] |
Author
Yes, you are right, v5 was old branch, v4 is correct.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I think v5 is wrong here. There is no v5 for 6.3 versions of Sugar. Maybe it's v4?