spotify-login
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Spotify Login - DEMO

npm versionLicense: MITBuild StatusDependenciesLanguage grade: JavaScript

How to install

It is possible to install with npm:

npm i spotify-login
// OR
yarn add spotify-login

Or import the script through the unpkg project:

<script src="https://unpkg.com/spotify-login/dist/spotify-login.js"></script>

How to usage

An example of how to use the webcomponent with html:

<spotify-login
  client-id="XXX"
  scope="user-read-email"
  redirect-uri="http://localhost:8000"
>
  <button>Login with Spotify</button>
</spotify-login>
 
<script>
  const spotifyLoginElement = document.querySelector("spotify-login");
 
  spotifyLoginElement.addEventListener("completed", e => {
    console.log(e.details);
  });
  spotifyLoginElement.addEventListener("fail", e => {
    console.log(e);
  });
</script> 

With JSX:

<spotify-login onCompleted={e => console.log(e)} onError={e => console.log(e)}>
  <button>Login with Spotify</button>
</spotify-login>

Properties

Property Attribute Description Type Default
clientId client-id Client ID for Spotify OAuth application string undefined
redirectUri redirect-uri The URI to redirect to after the user grants or denies permission. string undefined
responseType response-type Scope for Spotify OAuth application string "token"
scope scope Scope for Spotify OAuth application string undefined
showDialog show-dialog Whether or not to force the user to approve the app again if they’ve already done so. boolean undefined
state state The state can be useful for correlating requests and responses string undefined

Events

Event Description Type
completed Call with success CustomEvent<any>
fail Call with error CustomEvent<any>
request Call with request CustomEvent<any>

NPM Statistics

Download stats for this NPM package.

NPM

License

Spotify Login is open source software licensed as MIT.

Package Sidebar

Install

npm i spotify-login

Weekly Downloads

73

Version

0.2.0

License

MIT

Unpacked Size

769 kB

Total Files

67

Last publish

Collaborators

  • andrelmlins