Class: CosmosAuthentication::Service
- Inherits:
-
Cosmos::Service
- Object
- Cosmos::Service
- CosmosAuthentication::Service
- Defined in:
- lib/cosmos_authentication/service.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
- #resource_owner_class ⇒ Object
Instance Method Summary collapse
- #default_env ⇒ Object
- #get_token_via_code(code) ⇒ Object
- #get_token_via_password(username, password, scope = '') ⇒ Object
- #get_token_via_refresh_token(refresh_token, scope = '') ⇒ Object
- #providers ⇒ Object
- #resource_owner(access_token) ⇒ Object
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/cosmos_authentication/service.rb', line 7 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
7 8 9 |
# File 'lib/cosmos_authentication/service.rb', line 7 def client_secret @client_secret end |
#resource_owner_class ⇒ Object
58 59 60 |
# File 'lib/cosmos_authentication/service.rb', line 58 def resource_owner_class @resource_owner_class || ResourceOwner end |
Instance Method Details
#default_env ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/cosmos_authentication/service.rb', line 10 def default_env super.merge({ data: { client_id: client_id, client_secret: client_secret } }) end |
#get_token_via_code(code) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cosmos_authentication/service.rb', line 19 def get_token_via_code(code) get_token({ client_id: client_id, client_secret: client_secret, grant_type: 'code', code: code }) end |
#get_token_via_password(username, password, scope = '') ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cosmos_authentication/service.rb', line 28 def get_token_via_password(username, password, scope = '') get_token({ client_id: client_id, client_secret: client_secret, grant_type: 'password', username: username, password: password, scope: scope }) end |
#get_token_via_refresh_token(refresh_token, scope = '') ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/cosmos_authentication/service.rb', line 39 def get_token_via_refresh_token(refresh_token, scope = '') get_token({ client_id: client_id, client_secret: client_secret, grant_type: 'refresh_token', refresh_token: refresh_token }) end |
#providers ⇒ Object
48 49 50 |
# File 'lib/cosmos_authentication/service.rb', line 48 def providers get_providers end |
#resource_owner(access_token) ⇒ Object
52 53 54 55 56 |
# File 'lib/cosmos_authentication/service.rb', line 52 def resource_owner(access_token) resource_owner_class.new.tap do |resource_owner| resource_owner.collection = get_resource_owner(access_token) end end |