plangrade-ruby 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/plangrade/oauth2_client.rb +16 -26
- data/lib/plangrade/ruby/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4534d0455ce323b5b9a3895c1cb98889da6bb52
|
4
|
+
data.tar.gz: ad8e35b7ce70f104c6981c7d78394a3ebcfa2113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79a7c8509b7571d148eedc7de8ca6e29068f922f7d7097134e1963bdd608697cba738083c10832cfa15ea041cce9847ed8830b282e5bef49deefe87ec94ad382
|
7
|
+
data.tar.gz: 1f84282566199f2d4063b70f7b25ff6570a44011ea1801e7f50882867039fb46b451794cefdc77b82cc342dde652271645b979dd076fd30b4c45e24d586bdf99
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -16,24 +16,6 @@ module Plangrade
|
|
16
16
|
self
|
17
17
|
end
|
18
18
|
|
19
|
-
# Generates the Plangrade URL that the user will be redirected to in order to
|
20
|
-
# authorize your application
|
21
|
-
#
|
22
|
-
# @see http://docs.plangrade.com/#request-authorization
|
23
|
-
#
|
24
|
-
# @opts [Hash] additional parameters to be include in URL eg. scope, state, etc
|
25
|
-
#
|
26
|
-
# >> client = Plangrade::OAuth2Client.new('ETSIGVSxmgZitijWZr0G6w', '4bJZY38TCBB9q8IpkeualA2lZsPhOSclkkSKw3RXuE')
|
27
|
-
# >> client.webclient_authorization_url({
|
28
|
-
# :redirect_uri => 'http://localhost:3000/auth/plangrade/callback',
|
29
|
-
# })
|
30
|
-
# >> https://plangrade.com/oauth/authorize/?client_id={client_id}&
|
31
|
-
# redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2F%2Fplangrade%2Fcallback&response_type=token
|
32
|
-
#
|
33
|
-
def webclient_authorization_url(opts={})
|
34
|
-
implicit.token_url(opts)
|
35
|
-
end
|
36
|
-
|
37
19
|
# Generates the Plangrade URL that the user will be redirected to in order to
|
38
20
|
# authorize your application
|
39
21
|
#
|
@@ -61,7 +43,7 @@ module Plangrade
|
|
61
43
|
# @opts [Hash] may include redirect uri and other query parameters
|
62
44
|
#
|
63
45
|
# >> client = PlangradeClient.new(config)
|
64
|
-
# >> client.
|
46
|
+
# >> client.exchange_auth_code_for_token({
|
65
47
|
# :redirect_uri => 'http://localhost:3000/auth/plangrade/callback',
|
66
48
|
# })
|
67
49
|
#
|
@@ -71,7 +53,12 @@ module Plangrade
|
|
71
53
|
|
72
54
|
# client_id={client_id}&code=G3Y6jU3a&grant_type=authorization_code&
|
73
55
|
# redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fplangrade%2Fcallback&client_secret={client_secret}
|
74
|
-
def
|
56
|
+
def exchange_auth_code_for_token(opts={})
|
57
|
+
unless (opts[:params] && opts[:params][:code])
|
58
|
+
raise ArgumentError.new("You must include an authorization code as a parameter")
|
59
|
+
end
|
60
|
+
opts[:authenticate] ||= :body
|
61
|
+
code = opts[:params].delete(:code)
|
75
62
|
authorization_code.get_token(code, opts)
|
76
63
|
end
|
77
64
|
|
@@ -83,8 +70,8 @@ module Plangrade
|
|
83
70
|
# @opts [Hash] may include scope and other parameters
|
84
71
|
#
|
85
72
|
# >> client = PlangradeClient.new(config)
|
86
|
-
# >> client.
|
87
|
-
# :
|
73
|
+
# >> client.refresh_access_token({
|
74
|
+
# :refresh_token => 'asdfsadgrwerwet234523sdf',
|
88
75
|
# })
|
89
76
|
#
|
90
77
|
# POST /oauth/token HTTP/1.1
|
@@ -93,10 +80,13 @@ module Plangrade
|
|
93
80
|
|
94
81
|
# client_id={client_id}&refresh_token=G3Y6jU3a&grant_type=refresh_token&
|
95
82
|
# client_secret={client_secret}
|
96
|
-
def
|
97
|
-
opts[:
|
98
|
-
|
99
|
-
|
83
|
+
def refresh_access_token(opts={})
|
84
|
+
unless (opts[:params] && opts[:params][:refresh_token])
|
85
|
+
raise ArgumentError.new("You must provide a refresh_token as a parameter")
|
86
|
+
end
|
87
|
+
opts[:authenticate] = :body
|
88
|
+
token = opts[:params].delete(:refresh_token)
|
89
|
+
refresh_token.get_token(token, opts)
|
100
90
|
end
|
101
91
|
end
|
102
92
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|