Module: Vline
- Defined in:
- lib/vline.rb,
lib/vline/version.rb
Defined Under Namespace
Modules: AuthError, Helper
Classes: API
Constant Summary
collapse
- VERSION =
"0.0.8"
- @@service_id =
nil
- @@provider_id =
nil
- @@provider_secret =
nil
- @@client_id =
nil
- @@client_secret =
nil
- @@client_callback_url_base =
"https://api.vline.com/v1/auth"
- @@access_token_exp_time =
nil
- @@request_token_exp_time =
10.minutes
- @@login_token_exp_time =
2.weeks
Class Method Summary
collapse
Class Method Details
.auth_error_redirect_url(error, state) ⇒ Object
160
161
162
163
164
165
166
|
# File 'lib/vline.rb', line 160
def self.auth_error_redirect_url(error, state)
url = auth_url + "?error=" + error
if state
url += "&state=" + state
end
url
end
|
.auth_url ⇒ Object
156
157
158
|
# File 'lib/vline.rb', line 156
def self.auth_url
"#{Vline.client_callback_url_base}/#{Vline.service_id}/#{Vline.provider_id}"
end
|
.create_login_token(userId) ⇒ Object
172
173
174
175
176
|
# File 'lib/vline.rb', line 172
def self.create_login_token(userId)
payload = {'sub'=> Vline.provider_id + ':' + userId.to_s, 'iss'=> Vline.provider_id}
add_expiration(payload, Vline.login_token_exp_time)
JWT.encode(payload, JWT.base64url_decode(Vline.provider_secret))
end
|
.create_request_token(userId) ⇒ Object
168
169
170
|
# File 'lib/vline.rb', line 168
def self.create_request_token(userId)
create_token('req', userId, Vline.request_token_exp_time)
end
|
.launch_url_for(userId, targetUserId = nil) ⇒ Object
147
148
149
150
151
152
153
154
|
# File 'lib/vline.rb', line 147
def self.launch_url_for(userId, targetUserId=nil)
token = create_request_token(userId)
launch_url = auth_url
if targetUserId
launch_url += "/#{targetUserId}"
end
launch_url += "?code=#{token}"
end
|
.setup {|_self| ... } ⇒ Object
143
144
145
|
# File 'lib/vline.rb', line 143
def self.setup
yield self
end
|