Module: Setsuzoku::Service::WebService::Credentials::OAuthCredential
- Extended by:
- T::Helpers, T::Sig
- Includes:
- Credential, UsesTokenCredential
- Defined in:
- lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb
Instance Attribute Summary
Attributes included from Credential
#auth_strategy
Class Method Summary
collapse
Instance Method Summary
collapse
#auth_base_url, #expires_on, #expires_on=, #refresh_token, #refresh_token=, #token, #token=
Methods included from Credential
#settings, #settings=, #status, #status=
Class Method Details
.stub_credential ⇒ Object
81
82
83
84
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 81
def self.stub_credential
s = Struct.new(:auth_strategy, :status, :settings, :client_id, :client_secret, :redirect_url, :token, :refresh_token, :expires_on)
s.new(nil, 'active', {'extension': 'test'}, 'stubbed_client_id', 'stubbed_client_secret', 'stubbed_redirect_url', 'stubbed_token', 'stubbed_refresh_token', (Time.now + 30.days))
end
|
Instance Method Details
#auth_actions ⇒ Hash
All auth actions that are implemented.
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 24
def auth_actions
{
new_token: {
'POST' => 'token',
request_type: :json,
response_type: :json
},
refresh_token: {
'POST' => 'token',
request_type: :json,
response_type: :json
}
}
end
|
#client_id ⇒ Object
43
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 43
def client_id; end
|
#client_secret ⇒ Object
49
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 49
def client_secret; end
|
#redirect_url ⇒ Object
55
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 55
def redirect_url; end
|
#token_attributes_to_assign(resp) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb', line 63
def token_attributes_to_assign(resp)
attrs = {
token: resp.data[:access_token],
refresh_token: resp.data[:refresh_token]
}
expires_in = resp.data[:expires_in]
if expires_in && (expires_in.is_a?(Integer) || expires_in.match(/^\d+$/))
attrs[:expires_on] = expires_in.to_i.seconds.from_now
end
attrs
end
|