Class: SpotifyWebApi::OAuthAuthorizationController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::OAuthAuthorizationController
- Defined in:
- lib/spotify_web_api/controllers/o_auth_authorization_controller.rb
Overview
OAuthAuthorizationController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#refresh_token(authorization, refresh_token, scope: nil, _field_parameters: nil) ⇒ OAuthToken
Obtain a new access token using a refresh token Basic auth format space-delimited list.
-
#request_token(authorization, code, redirect_uri, _field_parameters: nil) ⇒ OAuthToken
Create a new OAuth 2 token.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from SpotifyWebApi::BaseController
Instance Method Details
#refresh_token(authorization, refresh_token, scope: nil, _field_parameters: nil) ⇒ OAuthToken
Obtain a new access token using a refresh token Basic auth format space-delimited list. supported by this endpoint.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/spotify_web_api/controllers/o_auth_authorization_controller.rb', line 54 def refresh_token(, refresh_token, scope: nil, _field_parameters: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/api/token', Server::AUTH_SERVER) .form_param(new_parameter('refresh_token', key: 'grant_type')) .header_param(new_parameter(, key: 'Authorization')) .form_param(new_parameter(refresh_token, key: 'refresh_token')) .form_param(new_parameter(scope, key: 'scope')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept')) .additional_form_params(_field_parameters)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OAuthToken.method(:from_hash)) .is_api_response(true) .local_error('400', 'OAuth 2 provider returned an error.', OAuthProviderException) .local_error('401', 'OAuth 2 provider says client authentication failed.', OAuthProviderException)) .execute end |
#request_token(authorization, code, redirect_uri, _field_parameters: nil) ⇒ OAuthToken
Create a new OAuth 2 token. Basic auth format supported by this endpoint.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/spotify_web_api/controllers/o_auth_authorization_controller.rb', line 17 def request_token(, code, redirect_uri, _field_parameters: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/api/token', Server::AUTH_SERVER) .form_param(new_parameter('authorization_code', key: 'grant_type')) .header_param(new_parameter(, key: 'Authorization')) .form_param(new_parameter(code, key: 'code')) .form_param(new_parameter(redirect_uri, key: 'redirect_uri')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept')) .additional_form_params(_field_parameters)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OAuthToken.method(:from_hash)) .is_api_response(true) .local_error('400', 'OAuth 2 provider returned an error.', OAuthProviderException) .local_error('401', 'OAuth 2 provider says client authentication failed.', OAuthProviderException)) .execute end |