<titledata-react-helmet="true">Implicit Grant | SpotifyAPI-NET</title><metadata-react-helmet="true"name="docsearch:version"content="next"><metadata-react-helmet="true"name="twitter:card"content="summary_large_image"><metadata-react-helmet="true"property="og:title"content="Implicit Grant | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="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."><metadata-react-helmet="true"property="og:description"content="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."><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET//docs/next/implicit_grant"><linkdata-react-helmet="true"rel="shortcut icon"href="/img/favicon.ico"><linkdata-react-helmet="true"rel="canonical"href="https://johnnycrazy.github.io/SpotifyAPI-NET//docs/next/implicit_grant"><linkrel="stylesheet"href="/styles.8a053330.css">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">// This call requires Spotify.Web.Auth</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">BrowserUtil.Open(uri);</span></div></div></div></div></div><p>After the user logged in and consented your app, your <code>UWP</code> app will receive a callback:</p><divclass="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">protected override void OnActivated(IActivatedEventArgs args)</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> if (args.Kind == ActivationKind.Protocol)</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> {</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var publisher = Mvx.IoCProvider.Resolve<ITokenPublisherService>();</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> // This Uri contains your access token in the Fragment part</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> Console.WriteLine(eventArgs.Uri);</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></div></div></div></div></div><p>For a real example, have a look at the <ahref="https://github.com/JohnnyCrazy/SpotifyAPI-NET/tree/master/SpotifyAPI.Web.Examples/Example.UWP">Example.UWP</a>, <ahref="https://github.com/JohnnyCrazy/SpotifyAPI-NET/tree/master/SpotifyAPI.Web.Examples/Example.ASP">Example.ASP</a> or <ahref="https://github.com/JohnnyCrazy/SpotifyAPI-NET/tree/master/SpotifyAPI.Web.Examples/Example.ASPBlazor">Example.ASPBlazor</a></p><h1><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="using-spotifywebauth"></a>Using Spotify.Web.Auth<aaria-hidden="true"tabindex="-1"class="hash-link"href="#using-spotifywebauth"title="Direct link to heading">#</a></h1><p>For cross-platform CLI and desktop apps (non <code>UWP</code> apps), custom protocol handlers are sometimes not an option. The fallback here is a small cross-platform embedded web server running on <code>http://localhost:5000</code> serving javascript. The javscript 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 event.</p><divclass="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">private static EmbedIOAuthServer _server;</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">public static async Task Main()</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> // Make sure "http://localhost:5000/callback" is in your spotify application as redirect uri!</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> _server = new EmbedIOAuthServer(new Uri("http://localhost:5000/callback"), 5000);</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> await _server.Start();</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">