@@ -11,40 +11,38 @@ This code was originally forked from [Leah Culver and Andy Smith's oauth.py code
11
11
12
12
# Signing a Request
13
13
14
- <pre ><code >
15
- import oauth2 as oauth
16
- import time
17
-
18
- # Set the API endpoint
19
- url = "http://example.com/photos"
20
-
21
- # Set the base oauth_* parameters along with any other parameters required
22
- # for the API call.
23
- params = {
24
- 'oauth_version': "1.0",
25
- 'oauth_nonce': oauth.generate_nonce(),
26
- 'oauth_timestamp': int(time.time())
27
- 'user': 'joestump',
28
- 'photoid': 555555555555
29
- }
30
-
31
- # Set up instances of our Token and Consumer. The Consumer.key and
32
- # Consumer.secret are given to you by the API provider. The Token.key and
33
- # Token.secret is given to you after a three-legged authentication.
34
- token = oauth.Token(key="tok-test-key", secret="tok-test-secret")
35
- consumer = oauth.Consumer(key="con-test-key", secret="con-test-secret")
36
-
37
- # Set our token/key parameters
38
- params['oauth_token'] = tok.key
39
- params['oauth_consumer_key'] = con.key
40
-
41
- # Create our request. Change method, etc. accordingly.
42
- req = oauth.Request(method="GET", url=url, parameters=params)
43
-
44
- # Sign the request.
45
- signature_method = oauth.SignatureMethod_HMAC_SHA1()
46
- req.sign_request(signature_method, consumer, token)
47
- </code ></pre >
14
+ import oauth2 as oauth
15
+ import time
16
+
17
+ # Set the API endpoint
18
+ url = "http://example.com/photos"
19
+
20
+ # Set the base oauth_* parameters along with any other parameters required
21
+ # for the API call.
22
+ params = {
23
+ 'oauth_version': "1.0",
24
+ 'oauth_nonce': oauth.generate_nonce(),
25
+ 'oauth_timestamp': int(time.time())
26
+ 'user': 'joestump',
27
+ 'photoid': 555555555555
28
+ }
29
+
30
+ # Set up instances of our Token and Consumer. The Consumer.key and
31
+ # Consumer.secret are given to you by the API provider. The Token.key and
32
+ # Token.secret is given to you after a three-legged authentication.
33
+ token = oauth.Token(key="tok-test-key", secret="tok-test-secret")
34
+ consumer = oauth.Consumer(key="con-test-key", secret="con-test-secret")
35
+
36
+ # Set our token/key parameters
37
+ params['oauth_token'] = tok.key
38
+ params['oauth_consumer_key'] = con.key
39
+
40
+ # Create our request. Change method, etc. accordingly.
41
+ req = oauth.Request(method="GET", url=url, parameters=params)
42
+
43
+ # Sign the request.
44
+ signature_method = oauth.SignatureMethod_HMAC_SHA1()
45
+ req.sign_request(signature_method, consumer, token)
48
46
49
47
# Using the Client
50
48
0 commit comments