npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wwdrew/expo-spotify-sdk

v0.4.2

Published

Expo Module for native Spotify SDK

Downloads

181

Readme

expo-spotify-sdk

An Expo Module for the native iOS and Android Spotify SDK

Supported Features

  • Authentication

More to come...

Installation

npx expo install @wwdrew/expo-spotify-sdk

Configuration

Include the expo-spotify-sdk plugin in your app.json/app.config.js file with its required configuration:

  ...
  "plugins": [
    ["@wwdrew/expo-spotify-sdk", {
      "clientID": "<your-spotify-client-id>",
      "scheme": "expo-spotify-sdk-example",
      "host": "authenticate"
    }]
  ],
  ...

Required:

  • clientID: <string> the Spotify Client ID for your application
  • scheme: <string> the URL scheme to link into your app as part of the redirect URI
  • host: <string> the path of the redirect URI

API Reference

isAvailable(): boolean`

Determines if the Spotify app is installed on the target device.


authenticateAsync(config: SpotifyConfig): Promise<SpotifySession>

Starts the authentication process. Requires an array of OAuth scopes. If the Spotify app is installed on the target device it will interact directly with it, otherwise it will open a web view to authenticate with the Spotify website.

Note for Android: If not providing a token swap or refresh URL, the Spotify session response access token will expire after 60 minutes and will not include a refresh token. This is due to a limitation in the Android Spotify SDK. It's recommended to implement a token swap endpoint for this reason.

Parameters

  • tokenSwapURL (optional): <string> The URL to use for attempting to swap an authorization code for an access token
  • tokenRefreshURL (optional): <string> The URL to use for attempting to renew an access token with a refresh token
  • scopes: An array of OAuth scopes that declare how your app wants to access a user's account. See Spotify Scopes for more information.

Note: The following scopes are not available to Expo Spotify SDK:

  • user-read-playback-position
  • user-soa-link
  • user-soa-unlink
  • user-manage-entitlements
  • user-manage-partner
  • user-create-partner

Types

interface SpotifyConfig {
  scopes: SpotifyScope[];
  tokenSwapURL?: string;
  tokenRefreshURL?: string;
}

interface SpotifySession {
  accessToken: string;
  refreshToken: string | null;
  expirationDate: number;
  scopes: SpotifyScopes[];
}

type SpotifyScopes =
  | "ugc-image-upload"
  | "user-read-playback-state"
  | "user-modify-playback-state"
  | "user-read-currently-playing"
  | "app-remote-control"
  | "streaming"
  | "playlist-read-private"
  | "playlist-read-collaborative"
  | "playlist-modify-private"
  | "playlist-modify-public"
  | "user-follow-modify"
  | "user-follow-read"
  | "user-top-read"
  | "user-read-recently-played"
  | "user-library-modify"
  | "user-library-read"
  | "user-read-email"
  | "user-read-private";

Token Swap Example

An example token swap endpoint has been provided in the example project. For it to work it needs your Spotify client details to be included.

  1. Open the server.js file and add your client details:
const CLIENT_ID = "<your-client-id>";
const CLIENT_SECRET = "<your-client-secret>";

These values can be found in your Spotify Developer Dashboard. You will need an existing Spotify app for this.

  1. Run the server
node server.js
  1. Set the tokenSwapURL value in your authenticateAsync call:
const session = await authenticateAsync({
  tokenSwapURL: "http://192.168.1.120:3000/swap",
  scopes: [
    ...
  ]
});

All authentication requests will now be sent through the token swap server.

Acknowledgments

This project has been heavily inspired by the following projects:

Contribute

Contributions are welcome!

License

MIT