httpclient 2.3.0.1 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +85 -0
- data/bin/httpclient +18 -6
- data/bin/jsonclient +85 -0
- data/lib/http-access2.rb +1 -1
- data/lib/httpclient.rb +262 -88
- data/lib/httpclient/auth.rb +269 -244
- data/lib/httpclient/cacert.pem +3952 -0
- data/lib/httpclient/cacert1024.pem +3866 -0
- data/lib/httpclient/connection.rb +1 -1
- data/lib/httpclient/cookie.rb +161 -514
- data/lib/httpclient/http.rb +57 -21
- data/lib/httpclient/include_client.rb +2 -0
- data/lib/httpclient/jruby_ssl_socket.rb +588 -0
- data/lib/httpclient/session.rb +259 -317
- data/lib/httpclient/ssl_config.rb +141 -188
- data/lib/httpclient/ssl_socket.rb +150 -0
- data/lib/httpclient/timeout.rb +1 -1
- data/lib/httpclient/util.rb +62 -1
- data/lib/httpclient/version.rb +1 -1
- data/lib/httpclient/webagent-cookie.rb +459 -0
- data/lib/jsonclient.rb +63 -0
- data/lib/oauthclient.rb +2 -1
- data/sample/jsonclient.rb +67 -0
- data/sample/oauth_twitter.rb +4 -4
- data/test/{ca-chain.cert → ca-chain.pem} +0 -0
- data/test/client-pass.key +18 -0
- data/test/helper.rb +10 -8
- data/test/jruby_ssl_socket/test_pemutils.rb +32 -0
- data/test/test_auth.rb +175 -4
- data/test/test_cookie.rb +147 -243
- data/test/test_http-access2.rb +17 -16
- data/test/test_httpclient.rb +458 -77
- data/test/test_jsonclient.rb +80 -0
- data/test/test_ssl.rb +341 -17
- data/test/test_webagent-cookie.rb +465 -0
- metadata +57 -55
- data/README.txt +0 -721
- data/lib/httpclient/cacert.p7s +0 -1858
- data/lib/httpclient/cacert_sha1.p7s +0 -1858
- data/sample/oauth_salesforce_10.rb +0 -63
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'oauthclient'
|
2
|
-
|
3
|
-
# Get your own consumer token from http://twitter.com/apps
|
4
|
-
consumer_key = '3MVG9y6x0357HledNGHa9tJrrlOmpCSo5alTv4W4AG1M0f9a8cGBIwo5wN2bQ7hjAEsjD7SBWf3H2Oycc9Qql'
|
5
|
-
consumer_secret = '1404017425765973464'
|
6
|
-
|
7
|
-
callback = ARGV.shift # can be nil for OAuth 1.0. (not 1.0a)
|
8
|
-
request_token_url = 'https://login.salesforce.com/_nc_external/system/security/oauth/RequestTokenHandler'
|
9
|
-
oob_authorize_url = 'https://login.salesforce.com/setup/secur/RemoteAccessAuthorizationPage.apexp'
|
10
|
-
access_token_url = 'https://login.salesforce.com/_nc_external/system/security/oauth/AccessTokenHandler'
|
11
|
-
|
12
|
-
STDOUT.sync = true
|
13
|
-
|
14
|
-
# create OAuth client.
|
15
|
-
client = OAuthClient.new
|
16
|
-
client.oauth_config.consumer_key = consumer_key
|
17
|
-
client.oauth_config.consumer_secret = consumer_secret
|
18
|
-
client.oauth_config.signature_method = 'HMAC-SHA1'
|
19
|
-
client.oauth_config.http_method = :get # Twitter does not allow :post
|
20
|
-
client.debug_dev = STDERR if $DEBUG
|
21
|
-
|
22
|
-
client.ssl_config.ssl_version = "TLSv1_1"
|
23
|
-
|
24
|
-
# Get request token.
|
25
|
-
res = client.get_request_token(request_token_url, callback)
|
26
|
-
p res.status
|
27
|
-
p res.oauth_params
|
28
|
-
p res.content
|
29
|
-
p client.oauth_config
|
30
|
-
token = res.oauth_params['oauth_token']
|
31
|
-
secret = res.oauth_params['oauth_token_secret']
|
32
|
-
raise if token.nil? or secret.nil?
|
33
|
-
|
34
|
-
# You need to confirm authorization out of band.
|
35
|
-
puts
|
36
|
-
puts "Go here and do confirm: #{oob_authorize_url}?oauth_token=#{token}&oauth_consumer_key=#{consumer_key}"
|
37
|
-
puts "Type oauth_verifier/PIN (if given) and hit [enter] to go"
|
38
|
-
verifier = gets.chomp
|
39
|
-
verifier = nil if verifier.empty?
|
40
|
-
|
41
|
-
# Get access token.
|
42
|
-
# FYI: You may need to re-construct OAuthClient instance here.
|
43
|
-
# In normal web app flow, getting access token and getting request token
|
44
|
-
# must be done in different HTTP requests.
|
45
|
-
# client = OAuthClient.new
|
46
|
-
# client.oauth_config.consumer_key = consumer_key
|
47
|
-
# client.oauth_config.consumer_secret = consumer_secret
|
48
|
-
# client.oauth_config.signature_method = 'HMAC-SHA1'
|
49
|
-
# client.oauth_config.http_method = :get # Twitter does not allow :post
|
50
|
-
res = client.get_access_token(access_token_url, token, secret, verifier)
|
51
|
-
p res.status
|
52
|
-
p res.oauth_params
|
53
|
-
p res.content
|
54
|
-
p client.oauth_config
|
55
|
-
id = res.oauth_params['user_id']
|
56
|
-
|
57
|
-
puts
|
58
|
-
puts "Access token usage example"
|
59
|
-
puts "Hit [enter] to go"
|
60
|
-
gets
|
61
|
-
|
62
|
-
# Access to a protected resource. (DM)
|
63
|
-
puts client.get("http://twitter.com/direct_messages.json")
|