plangrade-ruby 0.3.22 → 0.3.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28d0e4bf5b76d88ca44a62276da4d6432ca7b9f6
4
- data.tar.gz: a896fbc12562a8bc2aacde323f9a8466f994302a
3
+ metadata.gz: ecb0949e0cc91058f9f73270572ec1430024c60e
4
+ data.tar.gz: aed964c431dcfc9b084351fe17d7ce0567f51c73
5
5
  SHA512:
6
- metadata.gz: 38466fe4ba4a3a80791c3557be51fb86234a2fece2a97c433629077a9f82dc47a86754dc2b7177f3e4948e5f5beaa70bf00d7683eb7444f861329b357856479d
7
- data.tar.gz: 865a9d42ae45b87ed64511043a9771407cf46e3a0749cb827134247060fd2a485f9c6d81b23aafcc21ef435f08b72498fbecb15e7716db8f79ae8c20a02fb42f
6
+ metadata.gz: cd5fbc422ed5ad109cbf3e7fc807c26e100a9fffdc700efcf64616e357397804957d6dd2bdba69bce8bbd47f0ff0eab15fad84136f499a83bc5c4bc745890ac3
7
+ data.tar.gz: 9640f6b24614b22ba86792672a8239aa47cb78e92285a761ec18f1301bf569d568a1f21cb2cf037565e4f97e6d5117e8479a07c2ce13fff98a0a3600921f01ce
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- *o��.>�ln0(��|W���EG�@�nlr�1(O���Iz&�(!��
2
- ��bH��硑���˧�����u~X�N`�gO�@�p_��z?zD��Cxc�VE�`��J1�FX��Y#R��J��zYKE�t�q%�rrBjКD'�^|*zsͽ~t�-k�kh�F�e�$ n�+�O�hda4� ���6V��W�����}�;Q��D13�{�6��M�5��/P=��˛�O�h��� � w��~|֬ڼ��P'�vU
1
+ x��������BRٱ��|���y��gJ�)���7�\��H�yl�*� /T�Mޠң���S��]���`��7�#�"������a �^��DG���H�Sr�%��,�ݵ���|J�]2^hBR~j#����{l�o������bme,2��/ffh�eMK�g��54��@j4�X�1
2
+ :$%"t.-��?�[ֽ��� ����hVx*"+�ғ��j���P5�kH&�ҕ��KM\K��9*?�z;c����
data/README.md CHANGED
@@ -53,14 +53,14 @@ require 'plangrade'
53
53
 
54
54
  # Begin by getting the authorization url
55
55
  plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
56
- auth_url = plangrade_client.webserver_authorization_url(:redirect_uri => 'your_redirect_uri')
56
+ auth_url = plangrade_client.webserver_authorization_url(your_redirect_uri)
57
57
  ```
58
58
 
59
59
  After the user follows the link created above and authorizes your app, they will be redirected to your `redirect_uri`, with a code in the params that you can use to obtain an access token.
60
60
 
61
61
  ```ruby
62
62
  plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
63
- response = plangrade_client.exchange_auth_code_for_token({:params => {:code => params[:code], :redirect_uri => 'your_redirect_uri'}})
63
+ response = plangrade_client.exchange_auth_code_for_token(params[:code], your_redirect_uri)
64
64
  token = JSON.parse response.body
65
65
  access_token = token["access_token"]
66
66
  refresh_token = token["refresh_token"]
@@ -75,7 +75,7 @@ This gem also allows you to use a `refresh_token` to obtain a new `access_token`
75
75
  ```ruby
76
76
  # Set up a plangrade OAuth2 client and retrieve your refresh_token
77
77
  plangrade_client = Plangrade::OAuth2Client.new(ENV['PLANGRADE_CLIENT_ID'], ENV['PLANGRADE_CLIENT_SECRET'])
78
- response = plangrade_client.refresh_access_token({:params => {:refresh_token => 'your_refresh_token'}})
78
+ response = plangrade_client.refresh_access_token(your_refresh_token, your_redirect_uri)
79
79
  token = JSON.parse response.body
80
80
  access_token = token["access_token"]
81
81
  refresh_token = token["refresh_token"]
@@ -30,8 +30,8 @@ module Plangrade
30
30
  # >> https://plangrade.com/oauth/authorize/?client_id={client_id}&
31
31
  # redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fplangrade%2Fcallback&response_type=code
32
32
  #
33
- def webserver_authorization_url(opts={})
34
- opts[:scope] = normalize_scope(opts[:scope]) if opts[:scope]
33
+ def webserver_authorization_url(redirect)
34
+ opts = {:redirect_uri => redirect}
35
35
  authorization_code.authorization_url(opts)
36
36
  end
37
37
 
@@ -54,12 +54,9 @@ module Plangrade
54
54
 
55
55
  # client_id={client_id}&code=G3Y6jU3a&grant_type=authorization_code&
56
56
  # redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fplangrade%2Fcallback&client_secret={client_secret}
57
- def exchange_auth_code_for_token(opts={})
58
- unless (opts[:params] && opts[:params][:code])
59
- raise ArgumentError.new("You must include an authorization code as a parameter")
60
- end
61
- opts[:authenticate] ||= :body
62
- code = opts[:params].delete(:code)
57
+ def exchange_auth_code_for_token(code, redirect)
58
+ opts = {:params => {:redirect_uri => redirect}}
59
+ opts[:authenticate] = :body
63
60
  authorization_code.get_token(code, opts)
64
61
  end
65
62
 
@@ -81,13 +78,10 @@ module Plangrade
81
78
 
82
79
  # client_id={client_id}&refresh_token=G3Y6jU3a&grant_type=refresh_token&
83
80
  # client_secret={client_secret}
84
- def refresh_access_token(opts={})
85
- unless (opts[:params] && opts[:params][:refresh_token])
86
- raise ArgumentError.new("You must provide a refresh_token as a parameter")
87
- end
81
+ def refresh_access_token(ref_token, redirect)
82
+ opts = {:params => {:redirect_uri => redirect}}
88
83
  opts[:authenticate] = :body
89
- token = opts[:params].delete(:refresh_token)
90
- refresh_token.get_token(token, opts)
84
+ refresh_token.get_token(ref_token, opts)
91
85
  end
92
86
  end
93
87
  end
@@ -1,5 +1,5 @@
1
1
  module Plangrade
2
2
  module Ruby
3
- VERSION = "0.3.22"
3
+ VERSION = "0.3.23"
4
4
  end
5
5
  end
@@ -38,14 +38,9 @@ describe Plangrade::OAuth2Client do
38
38
  "client_id" => "PRbTcg9qjgKsp4jjpm1pw",
39
39
  "redirect_uri" => "https://localhost:3000/callback",
40
40
  "response_type" =>"code",
41
- "state" => "12345"
42
41
  }
43
42
 
44
- auth_url = subject.webserver_authorization_url(
45
- :client_id => 'PRbTcg9qjgKsp4jjpm1pw',
46
- :state => '12345',
47
- :redirect_uri => 'https://localhost:3000/callback'
48
- )
43
+ auth_url = subject.webserver_authorization_url('https://localhost:3000/callback')
49
44
 
50
45
  parsed_url = Addressable::URI.parse(auth_url)
51
46
  expect(parsed_url.path).to eq '/oauth/authorize'
@@ -72,12 +67,7 @@ describe Plangrade::OAuth2Client do
72
67
  'User-Agent' =>"Plangrade OAuth2 Client #{Plangrade::Ruby::VERSION}"
73
68
  })
74
69
 
75
- subject.exchange_auth_code_for_token(
76
- :params => {
77
- :code => 'MmOGL795LbIZuJJVnL49Cc',
78
- :redirect_uri => 'http://localhost:3000/callback'
79
- }
80
- )
70
+ subject.exchange_auth_code_for_token('MmOGL795LbIZuJJVnL49Cc', 'http://localhost:3000/callback')
81
71
  end
82
72
  end
83
73
 
@@ -98,12 +88,7 @@ describe Plangrade::OAuth2Client do
98
88
  'User-Agent' =>"Plangrade OAuth2 Client #{Plangrade::Ruby::VERSION}"
99
89
  })
100
90
 
101
- subject.refresh_access_token(
102
- :params => {
103
- :refresh_token => 'MmOGL795LbIZuJJVnL49Cc',
104
- :redirect_uri => 'http://localhost:3000/callback'
105
- }
106
- )
91
+ subject.refresh_access_token('MmOGL795LbIZuJJVnL49Cc', 'http://localhost:3000/callback')
107
92
  end
108
93
  end
109
94
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plangrade-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 0.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Reynoso
metadata.gz.sig CHANGED
Binary file