In this version we replaced use of WebView with 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.
To add this library to your project add following dependency to your app build.gradle file:
implementation "com.spotify.android:auth:<version>"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:
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 using spotify-sdk://auth redirect URI:
defaultConfig {
manifestPlaceholders = [redirectSchemeName: "spotify-sdk", redirectHostName: "auth"]
...
}Since Spotify Auth library version 3.0.0 you also need to provide the path pattern of your redirect URI
defaultConfig {
manifestPlaceholders = [
redirectSchemeName: "your-redirect-scheme",
redirectHostName: "your-redirect-host",
redirectPathPattern: "your/redirect/path/pattern" // New mandatory field
]
...
}If you want to retain the previous behavior (accepting any path), use .* as the path pattern. For more details, see the Google documentation.
To learn more see the Authentication Guide and the API reference.
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 Spotifystore- Redirects to the Android Play store to download the Spotify application
Complete API documentation is available for both library flavors:
- Auth Flavor Javadoc - Opens web browser for login
- Store Flavor Javadoc - Play Store fallback variant
Checkout the sample project.
You are welcome to contribute to this project. Please make sure that:
- New code is test covered
- Features and APIs are well documented
./gradlew checkmust succeed
This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.