https://github.com/spotify/android-auth
Spotify authentication and authorization for Android. Part of the Spotify Android SDK.
https://github.com/spotify/android-auth
android spotify spotify-authentication
Last synced: about 1 year ago
JSON representation
Spotify authentication and authorization for Android. Part of the Spotify Android SDK.
- Host: GitHub
- URL: https://github.com/spotify/android-auth
- Owner: spotify
- License: apache-2.0
- Created: 2016-10-17T18:58:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T12:25:26.000Z (about 2 years ago)
- Last Synced: 2025-03-29T14:08:38.912Z (about 1 year ago)
- Topics: android, spotify, spotify-authentication
- Language: HTML
- Homepage: https://github.com/spotify/android-sdk
- Size: 1.11 MB
- Stars: 145
- Watchers: 31
- Forks: 67
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Spotify Auth Library
[](https://search.maven.org/search?q=g:com.spotify.android)
# This repository is now a part of [spotify/android-sdk](https://github.com/spotify/android-sdk). Please post new issues there!
This library is responsible for authenticating the user and fetching the authorization code/access token
that can subsequently be used to play music or in requests to the [Spotify Web API](https://developer.spotify.com/web-api/).
# Breaking changes in Spotify Auth library version 2.0.0
In this version we replaced use of WebView with [Custom Tabs](https://developer.chrome.com/docs/android/custom-tabs/) since Google and Facebook Login no longer support WebViews for authenticating users.
As part of this change the library API does not contain `AuthorizationClient#clearCookies` method anymore. Custom Tabs use the cookies from the browser.
# Integrating the library into your project
To add this library to your project add following dependency to your app `build.gradle` file:
```gradle
implementation "com.spotify.android:auth:"
```
Since April 2021 we're publishing the library on MavenCentral instead of JCenter. Therefore to be able to get the library dependency, you should add MavenCentral into repositories block:
```gradle
repositories {
mavenCentral()
...
}
```
Since Spotify Auth library version 2.0.0 you also need to provide the scheme and host of the redirect URI that your app is using for authorizing in your app `build.gradle` file.
Below is an example of how this looks for [the auth sample project](auth-sample) using `spotify-sdk://auth` redirect URI:
```gradle
defaultConfig {
manifestPlaceholders = [redirectSchemeName: "spotify-sdk", redirectHostName: "auth"]
...
}
```
To learn more see the [Authentication Guide](https://developer.spotify.com/technologies/spotify-android-sdk/android-sdk-authentication-guide/)
and the [API reference](https://spotify.github.io/android-sdk/auth-lib/docs/index.html).
# Flavors
Since Spotify Auth library version 2.1.0, two versions of the library are provided that differs in
their behaviour if the Spotify application cannot be used to login:
* `auth` - Opens the web browser to login to Spotify
* `store` - Redirects to the Android Play store to download the Spotify application
# Sample Code
Checkout [the sample project](auth-sample).
# Contributing
You are welcome to contribute to this project. Please make sure that:
* New code is test covered
* Features and APIs are well documented
* `./gradlew check` must succeed
## Code of conduct
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md