Module: RSpotify
- Defined in:
- lib/rspotify.rb,
lib/rspotify/base.rb,
lib/rspotify/show.rb,
lib/rspotify/user.rb,
lib/rspotify/album.rb,
lib/rspotify/track.rb,
lib/rspotify/artist.rb,
lib/rspotify/device.rb,
lib/rspotify/player.rb,
lib/rspotify/episode.rb,
lib/rspotify/version.rb,
lib/rspotify/category.rb,
lib/rspotify/playlist.rb,
lib/rspotify/connection.rb,
lib/rspotify/track_link.rb,
lib/rspotify/audio_features.rb,
lib/rspotify/recommendations.rb,
lib/rspotify/recommendation_seed.rb
Defined Under Namespace
Classes: Album, Artist, AudioFeatures, Base, Category, Device, Episode, MissingAuthentication, Player, Playlist, RecommendationSeed, Recommendations, Show, Track, TrackLink, User
Constant Summary collapse
- VERSION =
'2.12.4'.freeze
- API_URI =
'https://api.spotify.com/v1/'.freeze
- AUTHORIZE_URI =
'https://accounts.spotify.com/authorize'.freeze
- TOKEN_URI =
'https://accounts.spotify.com/api/token'.freeze
- VERBS =
%w[get post put delete].freeze
Class Attribute Summary collapse
-
.client_token ⇒ Object
readonly
Returns the value of attribute client_token.
-
.raw_response ⇒ Object
Returns the value of attribute raw_response.
Class Method Summary collapse
-
.authenticate(client_id, client_secret) ⇒ Object
Authenticates access to restricted data.
- .resolve_auth_request(user_id, url) ⇒ Object
Class Attribute Details
.client_token ⇒ Object (readonly)
Returns the value of attribute client_token.
16 17 18 |
# File 'lib/rspotify/connection.rb', line 16 def client_token @client_token end |
.raw_response ⇒ Object
Returns the value of attribute raw_response.
15 16 17 |
# File 'lib/rspotify/connection.rb', line 15 def raw_response @raw_response end |
Class Method Details
.authenticate(client_id, client_secret) ⇒ Object
Authenticates access to restricted data. Requires user credentials
28 29 30 31 32 33 34 |
# File 'lib/rspotify/connection.rb', line 28 def authenticate(client_id, client_secret) @client_id, @client_secret = client_id, client_secret request_body = { grant_type: 'client_credentials' } response = RestClient.post(TOKEN_URI, request_body, auth_header) @client_token = JSON.parse(response)['access_token'] true end |
.resolve_auth_request(user_id, url) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rspotify/connection.rb', line 43 def resolve_auth_request(user_id, url) users_credentials = if User.class_variable_defined?('@@users_credentials') User.class_variable_get('@@users_credentials') end if users_credentials && users_credentials[user_id] User.oauth_get(user_id, url) else get(url) end end |