Class: RubyLokaliseApi::OAuth2::Auth
- Inherits:
-
Object
- Object
- RubyLokaliseApi::OAuth2::Auth
- Includes:
- BaseRequest
- Defined in:
- lib/ruby_lokalise_api/oauth2/auth.rb
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.
-
#open_timeout ⇒ Object
readonly
Returns the value of attribute open_timeout.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #auth(scope:, redirect_uri: nil, state: nil) ⇒ Object
- #base_url ⇒ Object
- #compression? ⇒ Boolean
-
#initialize(client_id, client_secret, params = {}) ⇒ Auth
constructor
A new instance of Auth.
- #refresh(token) ⇒ Object
- #token(code) ⇒ Object
Methods included from BaseRequest
#delete, #get, #patch, #post, #put
Methods included from Connection
Methods included from JsonHandler
Constructor Details
#initialize(client_id, client_secret, params = {}) ⇒ Auth
Returns a new instance of Auth.
10 11 12 13 14 15 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 10 def initialize(client_id, client_secret, params = {}) @client_id = client_id @client_secret = client_secret @timeout = params[:timeout] @open_timeout = params[:open_timeout] 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 |
#open_timeout ⇒ Object (readonly)
Returns the value of attribute open_timeout.
8 9 10 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 8 def open_timeout @open_timeout end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 8 def timeout @timeout end |
Instance Method Details
#auth(scope:, redirect_uri: nil, state: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 17 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 |
#base_url ⇒ Object
48 49 50 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 48 def base_url URI('https://app.lokalise.com/oauth2/') end |
#compression? ⇒ Boolean
52 53 54 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 52 def compression? false end |
#refresh(token) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 39 def refresh(token) params = base_params.merge({ refresh_token: token, grant_type: 'refresh_token' }) RubyLokaliseApi::OAuth2::Refresh.new post('token', self, params) end |
#token(code) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ruby_lokalise_api/oauth2/auth.rb', line 30 def token(code) params = base_params.merge({ code: code, grant_type: 'authorization_code' }) RubyLokaliseApi::OAuth2::Token.new post('token', self, params) end |