Commit Graph

58 Commits

Author SHA1 Message Date
Dj
b01adba826
Print -> Logging, fixes #84 (#461) 2020-04-03 23:03:09 +01:00
Loisaida Sam
ccfda079c8
Propagate refresh token error, fixes #259 (#261)
* Propagate refresh token error #259

https://github.com/plamere/spotipy/issues/259

* Lint

* Format

Co-authored-by: Stephane Bruckert <contact@stephanebruckert.com>
2020-04-02 20:03:24 +01:00
AlPoza
5b5b30dd0f
Add session in SpotifyAuthBase (#383)
Co-authored-by: XIS01536 <apozadel@extern.isban.es>
Co-authored-by: Stephane Bruckert <contact@stephanebruckert.com>
2020-04-01 23:02:56 +01:00
Stephane Bruckert
73aac90bbe Auto-close auth browser window 2020-04-01 21:25:48 +01:00
Zsolt Cserna
acdcfcecf8
oauth2.py: add local http server to serve redirects (#243)
When spotify redirects the browser to localhost, serve the page with a
simple http server implemented by HTTPServer. By this way, we can obtain
the tokens the oauth service want so provide us, and no need to input the
user the redirect URL.

This method only works when the application in spotify developer dashboard
is configured to redirect the requests to localhost.

To use this method it is required to specify the redirect_url pointing to
localhost with simple http, to a non-privilegized port (unless the script is
run as root).
2020-04-01 18:16:13 +01:00
Ritiek Malhotra
4d1dbfe3ca
Remove unnecessary print statements
which show up when fetching access token using:

```python
credentials = oauth2.SpotifyClientCredentials(
    client_id=client_id,
   client_secret=client_secret,
)
token = credentials.get_access_token()
```
2020-03-02 17:32:17 +05:30
pearce
d71913d087 Made cache optional in get_access_token #441 2020-02-15 19:23:51 +00:00
Alexey Paramonov
1f1e90ed39
Add requests_timeout parameter to auth module (#233) 2020-02-13 00:04:40 +00:00
Stephane Bruckert
94a26407a7 Fix integration tests 2020-02-12 22:27:42 +00:00
JohannesPertl
04bdd27d85
Prompt option to always show a dialog when giving permissions to Spotify (#438)
* Add show_dialog option to prompt_for_user_token()

* Adjust test_get_authorize_url_shows_dialog_when_requested
2020-02-12 20:49:26 +00:00
Stefano
4515446a65 Auto-refresh AuthCode flow token. (#435)
* Auto-refresh AuthCode flow token.

* Reformatted.

* Reformatted.

* Removed invalid syntax.

* Removed abstract class SpotifyAuthManager.

* Fix typo on docstrings.

* Optionally try to fetch main input parameters from environment.

Implements the capability of trying to fetch the following parameters from the environment, when they're not directly passed to the authorization handler.
The affected parameters are: client_id, client_secret, redirect_uri.
An SpotifyOauthError is raised if no value gets found.

* Removed f-string for Python2 compatibility.

* Fix line-too-long.

* Remove useless import.

* Add username to docstring.

* Remove redundant return.

* Fix empty lines print statement for backward compatibility with Python2.

* Update simple4 example.

* Set optional 'as_dict' parameter on OAuth 'get_access_token'.

* Update changelog.

Co-authored-by: Stéphane Bruckert <stephane.bruckert@gmail.com>
2020-02-10 10:20:02 +00:00
S Murthy
3b0e8febc4
Linting of core subpackage + clean up imports (#437)
* Linting of OAuth2 mod. + update tests to detect core package path

* Tweak imports in tests + update tox ini to ignore Flake8 E501 error

* Tweak tox ini - ignore examples

* Remove `f`-string from OAuth2 mod.

* More import tweaks in core package + tests

* Update flake8 config. in tox ini - set line length limit to 99 chars.
2020-02-09 12:59:20 +00:00
Stephane Bruckert
26db832e24 Temporarily revert #428 2020-01-23 10:06:19 +00:00
Peter
87a72a060f Automatic refresh of Authorization Code Flow Tokens in long-running Applications (#428)
* auto-refresh user token

* example for a long-running user-request app

* wrap long lines

* combine duplicate code into _refresh_token_if_expired method

* add changelog entry
2020-01-22 20:01:30 +00:00
Stéphane Bruckert
c3bad99e43
Revert "Remove unnecessary token_info parameter for oauth2.SpotifyClientCredentials methods (#223)" (#417)
This reverts commit 908a92897b.
2020-01-12 15:14:25 +00:00
Ritiek Malhotra
908a92897b Remove unnecessary token_info parameter for oauth2.SpotifyClientCredentials methods (#223) 2020-01-12 15:13:31 +00:00
Stéphane Bruckert
f54830e272
Add linter, solves #348 (#415) 2020-01-12 13:19:40 +00:00
Stéphane Bruckert
53c4f30e9c
Merge pull request #368 from s2t2/patch-1
Update oauth2 Docs
2020-01-12 00:12:23 +00:00
Sandeep Murthy
e1ba4a9bbb Re-order imports and specify UTF-8 encoding header in all base modules and package initialiser (ref. https://www.python.org/dev/peps/pep-0008/#imports, https://www.python.org/dev/peps/pep-0008/#source-file-encoding) + add __all__ attribute 2020-01-11 19:54:20 +00:00
Mike Rossetti
d588d22a2d
Update oauth2.py 2019-04-14 21:30:16 -04:00
Paul Lamere
d31214642d Merge pull request #206 from lastfm/feature/add-show-dialog-auth-option
Add show_dialog auth url option
2017-09-17 11:57:01 -04:00
Paul Lamere
9054cfecfb Merge pull request #185 from ncordon/patch-1
Changes critical is not for !=
2017-09-17 11:50:08 -04:00
Thomas Hooper
6c3c384bf0 Add show_dialog auth url option
Optional. Whether or not to force the user to approve the app again if they’ve already done so. If false (default), a user who has already approved the application may be automatically redirected to the URI specified by redirect_uri. If true, the user will not be automatically redirected and will have to approve the app again.

From https://developer.spotify.com/web-api/authorization-guide/
2017-08-02 10:36:10 +01:00
Nacho Cordón
5171911342 Changes critical is not for != 2017-04-14 21:04:24 +02:00
Richard Mitic
dab5e08b7a Token cache handles null scopes correctly 2017-04-01 10:03:46 +02:00
Paul Lamere
dc996b363f Merge pull request #158 from josduj/master
Fixes error when scope is not set
2017-01-18 17:58:22 -05:00
josduj
4f15a6f07e Fixes error when scope is not set 2017-01-18 10:26:14 +01:00
Michael Birtwell
d092683be3 Make is_token_expired public
Make is_token_expired_public on SpotifyClientCredentials and SpotifyOAuth.
This method is useful for checking whether tokens that have been stored in cookies etc have timed out. So it's useful for library users to have access to it.

Refactor common implementation of is_token_expired
2017-01-07 16:21:13 +00:00
Paul Lamere
f638b0c59b Merge pull request #149 from mbirtwell/python3_with_six
Use six to simplify python 2/3 compatibilty code where possible
2017-01-07 10:55:43 -05:00
Michael Birtwell
72a2fe489d Use six to simplify python 2/3 compatibilty code where possible 2017-01-07 15:18:46 +00:00
Michael Birtwell
5aadb284ff Add support for setting state in get_authorise_url
This allows for example putting a next page url in the state to be loaded after authorization completes.
2017-01-07 13:13:35 +00:00
Paul Lamere
c8ff4b960a Fixed proxy issue 2017-01-02 12:11:27 -05:00
Sebastian Bischoff
1ef89cfd2c Merge branch 'master' into proxy 2017-01-02 14:43:40 +01:00
Paul Lamere
cb2d385845 Merge pull request #71 from myselfhimself/myselfhimself-scope-subsets
OAuth2: Avoid token renewal when scopes are subset of one another
2016-12-31 18:56:35 -05:00
Paul Lamere
07b6c052e3 Merge pull request #109 from lwoloszy/master
Get new access token 60 seconds before old one times out
2016-12-31 17:56:42 -05:00
Sebastian Bischoff
96e9d3b7df Added support for proxy 2016-08-23 16:48:49 +02:00
Luke Woloszyn
ff7b0f3e2a get new access token ~60 seconds before old one times out 2016-07-27 08:10:45 -07:00
eugenio412
83e42efa88 include refresh_access_token method to the library
in this way it's possible to refresh token even if it's not cached but saved somewhere else
2016-04-08 17:12:31 +02:00
myselfhimself
8de2591c18 Avoid unneeded token renewal when cached token's scope contains currently required scope
Before that there was a strict string comparision "cached scope" == "currently required scope". Added a scope subset detection method.
2015-12-02 20:56:44 +01:00
Joona Hoikkala
c944cc772f Fixes for the remaining base64 lib references 2015-06-05 13:17:58 +03:00
Joona Hoikkala
a541b3bb81 Support both Python 2 & 3 base64 library 2015-06-05 13:12:36 +03:00
Ryan
a3a68be7bc ascii decode in _refresh_access_token 2015-06-05 12:21:37 +03:00
Joona Hoikkala
d6a14bc83d Urllib compatibility fix to support both python 2 & 3 2015-06-05 12:16:30 +03:00
Joona Hoikkala
d08f7a82dc Support print() as function in Python 2 2015-06-05 12:14:13 +03:00
Joona Hoikkala
f19682cc80 Fixed (byte)string handling when calling base64 lib 2015-06-05 12:11:06 +03:00
Joona Hoikkala
1f833afa45 Initial run of 2to3 2015-06-05 12:07:28 +03:00
Faruk Sahin
8d4643c2e1 Add client credentials flow 2015-04-01 16:09:54 +02:00
Paul Lamere
b455d529f0 Doc improvements for readthedocs 2014-08-22 11:48:12 -04:00
Paul Lamere
20870ea3ed Documentation improvements 2014-08-22 11:00:29 -04:00
Paul Lamere
080786654a Improved oauth docs 2014-08-22 09:23:06 -04:00