Module: Croudia::API::OAuth
- Included in:
- Client
- Defined in:
- lib/croudia/api/oauth.rb
Instance Method Summary collapse
-
#authorize_url(params = {}) ⇒ String
Authorize URL.
-
#get_access_token(code, params = {}) ⇒ Croudia::AccessToken
Retrieve access_token.
Instance Method Details
#authorize_url(params = {}) ⇒ String
Authorize URL
14 15 16 17 18 |
# File 'lib/croudia/api/oauth.rb', line 14 def (params={}) params[:client_id] ||= @client_id params[:response_type] ||= 'code' connection.build_url('/oauth/authorize', params).to_s end |
#get_access_token(code, params = {}) ⇒ Croudia::AccessToken #get_access_token(params = {}) ⇒ Croudia::AccessToken
Retrieve access_token
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/croudia/api/oauth.rb', line 36 def get_access_token(code, params={}) case code when String, Integer params[:code] ||= code when Hash params = code.merge(params) end params[:client_id] ||= @client_id params[:client_secret] ||= @client_secret params[:grant_type] ||= 'authorization_code' resp = post('/oauth/token', params) Croudia::AccessToken.new(resp) end |