Welcome to spotifylib’s documentation!¶
Contents:
spotifylib¶
Spotify API Client
This library aims to implement Spotify’s Authorization flow without the user needing to create a third party application to authorize the application, redirect it to the callback and then manually authorize it with username and password.
The user will only need to create an application under his/her developer site and get Client ID, Client Secret and provide a Redirect URI - http://127.0.0.1/callback would just work.
Up until this point, the user will need to provide a scope to get a token that has access to the resources. Read more about scopes here
Read more on USAGE.rst
Features¶
- TODO
Installation¶
At the command line:
$ pip install spotifylib
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv spotifylib
$ pip install spotifylib
Usage¶
To use spotifylib in a project:
from spotifylib import Spotify
import os
spotify = Spotify(client_id=os.environ.get('CLIENT_ID'),
client_secret=os.environ.get('CLIENT_SECRET'),
username=os.environ.get('USERNAME'),
password=os.environ.get('PASSWORD'),
callback=os.environ.get('CALLBACK_URL'),
scope=os.environ.get('SCOPE'))
print(spotify.token.access_token)
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Submit Feedback¶
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
Get Started!¶
Ready to contribute? Here’s how to set up spotifylib for local development.
Clone your fork locally:
$ git clone git@spotifylib
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your clone for local development:
$ mkvirtualenv spotifylib $ cd spotifylib/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
Commit your changes and push your branch to the server:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a merge request
spotifylib¶
spotifylib package¶
Submodules¶
spotifylib.spotifylib module¶
This module makes use of Spotipy’s methods but modifying the authentication in a simple and transparent way from the user without any need of 3rd party application to follow the OAuth flow as mentioned in the following documentation page.
https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow
-
class
spotifylib.spotifylib.
Spotify
[source]¶ Bases:
object
Library’s interface object
Instantiates the authentication object to figure out the token and passes it alongside the session to Spotipy’s in order to use its methods.
-
class
spotifylib.spotifylib.
SpotifyAuthenticator
(client_id, client_secret, username, password, callback, scope)[source]¶ Bases:
object
Authenticator object
This object handles authentication for all requests. In order to retrieve all values for this to work, one has to create a new application under his/her account.
https://developer.spotify.com/my-applications/#!/applications
-
token
¶
-
spotifylib.spotifylibexceptions module¶
Main module Exceptions file
Put your exception classes here
-
exception
spotifylib.spotifylibexceptions.
SpotifyError
[source]¶ Bases:
exceptions.Exception
# Wrong client_id (<Response [400]>, ‘INVALID_CLIENT: Invalid client’)
# Wrong response_type (<Response [400]>, ‘response_type must be code or token’)
# Invalid scope (<Response [400]>, ‘INVALID_SCOPE: Invalid scope’)
# Invalid CSRF cookie (<Response [400]>, ‘{“error”:”errorCSRF”}’)
# Invalid redirect_uri (<Response [400]>, ‘Illegal redirect_uri’) “Error while accepting APP to Spotify API”
Credits¶
Development Lead¶
- Costas Tyfoxylos <https://github.com/costastf>
Contributors¶
- Oriol Fabregas <fabregas.oriol@gmail.com>
History¶
0.1 (18-09-2017)¶
- First release