Class: RubyLokaliseApi::OAuth2::Auth
- Inherits:
-
Object
- Object
- RubyLokaliseApi::OAuth2::Auth
- Includes:
- Request
- Defined in:
- lib/ruby_lokalise_api/oauth2/auth.rb
Constant Summary
Constants included from Connection
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
Instance Method Summary collapse
- #auth(scope:, redirect_uri: nil, state: nil) ⇒ Object
-
#initialize(client_id, client_secret) ⇒ Auth
constructor
A new instance of Auth.
- #refresh(token) ⇒ Object
- #token(code) ⇒ Object
Methods included from Request
Methods included from Connection
Methods included from JsonHandler
Constructor Details
#initialize(client_id, client_secret) ⇒ Auth
Returns a new instance of Auth.
10 11 12 13 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 10 def initialize(client_id, client_secret) @client_id = client_id @client_secret = client_secret end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 8 def client_secret @client_secret end |
Instance Method Details
#auth(scope:, redirect_uri: nil, state: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 15 def auth(scope:, redirect_uri: nil, state: nil) scope = scope.join(' ') if scope.is_a?(Array) params = { client_id: client_id, scope: scope } params[:state] = state unless state.nil? params[:redirect_uri] = redirect_uri unless redirect_uri.nil? _build_url_from params end |
#refresh(token) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 36 def refresh(token) params = base_params.merge({ refresh_token: token, grant_type: 'refresh_token' }) post 'token', params end |
#token(code) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 28 def token(code) params = base_params.merge({ code: code, grant_type: 'authorization_code' }) post 'token', params end |