Implicit Grant
Implicit grant flow is for clients that are implemented entirely using JavaScript and running in the resource owner’s browser. You do not need any server-side code to use it. Rate limits for requests are improved but there is no refresh token provided. This flow is described in RFC-6749.
This flow is useful for getting a user access token for a short timespan.
#
Existing Web-ServerIf you are already in control of a Web-Server (like ASP.NET
), you can start the flow by generating a login uri:
When the user is redirected to the generated uri, they will have to login with their Spotify account and confirm that your application wants to access their user data. Once confirmed, they will be redirected to http://localhost:5000
and the fragment identifier (#
part of URI) will contain an access token.
warning
Note, this parameter is not sent to the server! You need JavaScript to access it.
#
Using custom ProtocolsThis flow can also be used with custom protocols instead of http
/https
. This is especially interesting for UWP
apps, since your able to register custom protocol handlers quite easily.
The process is very similar, you generate a uri and open it for the user:
After the user has logged in and consented your app, your UWP
app will receive a callback:
For a real example, have a look at the Example.UWP, Example.ASP or Example.ASPBlazor
#
Using Spotify.Web.AuthFor cross-platform CLI and desktop apps (non UWP
apps), custom protocol handlers are sometimes not an option. The fallback here is a small cross-platform embedded web server running on http://localhost:5000
serving JavaScript. The JavaScript will parse the fragment part of the URI and sends a request to the web server in the background. The web server then notifies your appliciation via an event.
For real examples, have a look at Example.CLI.PersistentConfig and Example.CLI.CustomHTML