spotify-login
v0.2.0
Published
Web Component for Spotify Login
Downloads
238
Maintainers
Readme
Spotify Login - DEMO
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.
License
Spotify Login is open source software licensed as MIT.