@superfan-app/spotify-auth 0.1.67 → 0.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,9 +6,10 @@ A modern Expo module for Spotify authentication in React Native apps. This modul
6
6
 
7
7
  - 🔐 Complete Spotify OAuth implementation
8
8
  - 🔄 Automatic token refresh
9
- - 📱 iOS support via native SDK
9
+ - 📱 iOS support via native Spotify SDK
10
+ - 🤖 Android support via Spotify Auth Library
10
11
  - ⚡️ Modern Expo development workflow
11
- - 🛡️ Secure token storage
12
+ - 🛡️ Secure token storage (Keychain on iOS, EncryptedSharedPreferences on Android)
12
13
  - 🔧 TypeScript support
13
14
  - 📝 Comprehensive error handling
14
15
 
@@ -57,7 +58,9 @@ npx expo install expo-dev-client
57
58
  - Format: `your-app-scheme://callback`
58
59
  - Example: `my-spotify-app://callback`
59
60
 
60
- 4. Implement token swap/refresh endpoints on your backend (see Backend Requirements below)
61
+ 4. **Android only:** Register your app's [SHA-1 fingerprint](https://developer.spotify.com/documentation/android/tutorials/application-fingerprints) in the Spotify Developer Dashboard.
62
+
63
+ 5. Implement token swap/refresh endpoints on your backend (see Backend Requirements below)
61
64
 
62
65
  ## Usage
63
66
 
@@ -203,6 +206,11 @@ npx expo prebuild --clean
203
206
  npx expo run:ios
204
207
  ```
205
208
 
209
+ 4. Run on Android:
210
+ ```bash
211
+ npx expo run:android
212
+ ```
213
+
206
214
  ## Troubleshooting
207
215
 
208
216
  ### Common Issues
@@ -229,7 +237,7 @@ npx expo run:ios
229
237
  ## Security
230
238
 
231
239
  - Access tokens are stored in memory
232
- - Refresh tokens are securely stored in Keychain
240
+ - Refresh tokens are securely stored in Keychain (iOS) / EncryptedSharedPreferences (Android)
233
241
  - HTTPS required for token endpoints
234
242
  - Automatic token refresh
235
243
  - Proper error handling and recovery
@@ -238,11 +246,14 @@ npx expo run:ios
238
246
 
239
247
  - Expo SDK 53+
240
248
  - iOS 15.1+
249
+ - Android API 24+ (Android 7.0+)
241
250
  - Swift 5.9 (Xcode 15+)
242
251
  - Node.js 20.0+
243
252
  - Expo Development Client
244
253
 
245
- ## iOS Native Notes
254
+ ## Platform Notes
255
+
256
+ ### iOS
246
257
 
247
258
  - The Spotify SDK is bundled as a vendored `SpotifyiOS.xcframework`. CocoaPods configures header and framework search paths automatically. You do not need to add manual `HEADER_SEARCH_PATHS` or `FRAMEWORK_SEARCH_PATHS`.
248
259
  - If you hit CocoaPods build issues after installing, try:
@@ -251,3 +262,54 @@ cd ios
251
262
  pod deintegrate
252
263
  pod install --repo-update
253
264
  ```
265
+
266
+ ### Android
267
+
268
+ The Spotify Auth Library (`spotify-auth-release-2.1.0.aar`) v2.1.0 is bundled in `android/Frameworks/`. It handles both app-switch auth (when Spotify is installed) and WebView fallback (when it's not).
269
+
270
+ #### Android Setup (if iOS is already configured)
271
+
272
+ If you already have iOS working, Android requires no changes to your `app.config.js` — the same plugin config drives both platforms. However, you do need to complete these additional steps in the Spotify Developer Dashboard:
273
+
274
+ 1. **Register your Android package name and SHA-1 fingerprint** in the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard):
275
+ - Go to your app → Edit Settings → Android Packages
276
+ - Add your package name (e.g. `com.yourcompany.yourapp`)
277
+ - Add your SHA-1 fingerprint(s)
278
+
279
+ 2. **Generate your SHA-1 fingerprint:**
280
+
281
+ For **debug** builds:
282
+ ```bash
283
+ keytool -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v | grep SHA1
284
+ ```
285
+ Default password: `android`
286
+
287
+ For **release** builds:
288
+ ```bash
289
+ keytool -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEYSTORE_PATH> -list -v | grep SHA1
290
+ ```
291
+
292
+ > We strongly recommend registering both debug and release fingerprints. See [Application Fingerprints](https://developer.spotify.com/documentation/android/tutorials/application-fingerprints) for details.
293
+
294
+ 3. **Ensure the redirect URI** (`your-app-scheme://callback`) is added in the Spotify Dashboard under "Redirect URIs" (this is shared with iOS — likely already done).
295
+
296
+ 4. **Rebuild your app:**
297
+ ```bash
298
+ npx expo prebuild --clean
299
+ npx expo run:android
300
+ ```
301
+
302
+ #### What the config plugin does (Android)
303
+
304
+ The Expo config plugin automatically handles:
305
+ - Injecting `<meta-data>` entries into `AndroidManifest.xml` for `SpotifyClientID`, `SpotifyRedirectURL`, `SpotifyScopes`, `SpotifyTokenSwapURL`, and `SpotifyTokenRefreshURL`
306
+ - Adding an `<intent-filter>` to your main activity for the redirect URI scheme and host
307
+
308
+ You do **not** need to manually edit `AndroidManifest.xml`.
309
+
310
+ #### Android-specific behavior
311
+
312
+ - The `campaign` parameter in `AuthorizeConfig` is **ignored** on Android (not supported by the Spotify Android auth library).
313
+ - Secure token storage uses `EncryptedSharedPreferences` (AES-256) instead of Keychain.
314
+ - When the Spotify app is installed, authentication uses an app-switch flow (no password entry needed). When it's not installed, a WebView fallback is used automatically.
315
+ - Authentication retry for user-interactive flows (e.g. the initial authorization) cannot be retried automatically — the error is reported to JS so your app can prompt the user to try again.
@@ -0,0 +1,99 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+ apply plugin: 'maven-publish'
4
+
5
+ group = 'expo.modules.spotifyauth'
6
+ version = '0.1.0'
7
+
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ }
13
+
14
+ // Some Expo setups also expect this in buildscript; keeping it for compatibility.
15
+ buildscript {
16
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
17
+ if (expoModulesCorePlugin.exists()) {
18
+ apply from: expoModulesCorePlugin
19
+ applyKotlinExpoModulesCorePlugin()
20
+ }
21
+ }
22
+
23
+ afterEvaluate {
24
+ publishing {
25
+ publications {
26
+ release(MavenPublication) {
27
+ from components.release
28
+ }
29
+ }
30
+ repositories {
31
+ maven {
32
+ url = mavenLocal().url
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ android {
39
+ namespace "expo.modules.spotifyauth"
40
+
41
+ compileSdkVersion safeExtGet("compileSdkVersion", 35)
42
+
43
+ defaultConfig {
44
+ minSdkVersion safeExtGet("minSdkVersion", 24)
45
+ targetSdkVersion safeExtGet("targetSdkVersion", 35)
46
+ }
47
+
48
+ // Allow publishing a sources jar for the release variant
49
+ publishing {
50
+ singleVariant("release") {
51
+ withSourcesJar()
52
+ }
53
+ }
54
+
55
+ lintOptions {
56
+ abortOnError false
57
+ }
58
+
59
+ compileOptions {
60
+ sourceCompatibility JavaVersion.VERSION_17
61
+ targetCompatibility JavaVersion.VERSION_17
62
+ }
63
+
64
+ kotlinOptions {
65
+ jvmTarget = JavaVersion.VERSION_17.majorVersion
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Resolve Kotlin version safely.
71
+ * Prefer the root project's configured Kotlin version (most common in RN/Expo),
72
+ * fall back to a pinned version if none is defined.
73
+ */
74
+ def resolvedKotlinVersion() {
75
+ if (rootProject.ext.has('kotlinVersion')) {
76
+ return rootProject.ext.kotlinVersion
77
+ }
78
+ if (project.ext.has('kotlinVersion')) {
79
+ return project.ext.kotlinVersion
80
+ }
81
+ // Fallback: keep this aligned with your app if you pin Kotlin elsewhere.
82
+ return '2.0.21'
83
+ }
84
+
85
+ dependencies {
86
+ implementation project(':expo-modules-core')
87
+
88
+ // Spotify Auth Library (local .aar)
89
+ implementation files('Frameworks/spotify-auth-release-2.1.0.aar')
90
+
91
+ // Required for Spotify Auth Library's browser-based fallback
92
+ implementation 'androidx.browser:browser:1.8.0'
93
+ implementation 'androidx.appcompat:appcompat:1.7.0'
94
+
95
+ // For secure storage of refresh tokens
96
+ implementation 'androidx.security:security-crypto:1.1.0-alpha06'
97
+
98
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:${resolvedKotlinVersion()}"
99
+ }
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <!-- No permissions needed at the library level.
3
+ The config plugin will add intent-filters to the host app's manifest. -->
4
+ </manifest>