<titledata-react-helmet="true">Client Credentials | SpotifyAPI-NET</title><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/client_credentials"><metadata-react-helmet="true"name="docusaurus_locale"content="en"><metadata-react-helmet="true"name="docusaurus_version"content="current"><metadata-react-helmet="true"name="docusaurus_tag"content="docs-default-current"><metadata-react-helmet="true"property="og:title"content="Client Credentials | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="The Client Credentials flow is used in server-to-server authentication."><metadata-react-helmet="true"property="og:description"content="The Client Credentials flow is used in server-to-server authentication."><linkdata-react-helmet="true"rel="shortcut icon"href="/SpotifyAPI-NET/img/favicon.ico"><linkdata-react-helmet="true"rel="canonical"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/client_credentials"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/client_credentials"hreflang="en"><linkdata-react-helmet="true"rel="alternate"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/client_credentials"hreflang="x-default"><linkrel="stylesheet"href="/SpotifyAPI-NET/assets/css/styles.834af7f3.css">
Only endpoints that do not access user information can be accessed.</p></blockquote><p>By supplying your <code>SPOTIFY_CLIENT_ID</code> and <code>SPOTIFY_CLIENT_SECRET</code>, you get an access token.</p><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="request-token-once"></a>Request token once<aclass="hash-link"href="#request-token-once"title="Direct link to heading">#</a></h2><p>To request an access token, build a <code>ClientCredentialsRequest</code> and send it via <code>OAuthClient</code>. This access token will expire after some time and you need to repeat the process.</p><divclass="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><pretabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"style="color:#bfc7d5;background-color:#292d3e"><codeclass="codeBlockLines_39YC"><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">public static async Task Main()</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var config = SpotifyClientConfig.CreateDefault();</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">
</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var request = new ClientCredentialsRequest("CLIENT_ID", "CLIENT_SECRET");</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var response = await new OAuthClient(config).RequestToken(request);</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">
</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var spotify = new SpotifyClient(config.WithToken(response.AccessToken));</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></span></code></pre><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_Ue-o clean-btn">Copy</button></div></div><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_2LWZ"id="request-token-on-demand"></a>Request Token On-Demand<aclass="hash-link"href="#request-token-on-demand"title="Direct link to heading">#</a></h2><p>You can also use <code>CredentialsAuthenticator</code>, which will make sure the Spotify instance will always have an up-to-date access token by automatically refreshing the token on demand.</p><divclass="codeBlockContainer_K1bP"><divclass="codeBlockContent_hGly csharp"><pretabindex="0"class="prism-code language-csharp codeBlock_23N8 thin-scrollbar"style="color:#bfc7d5;background-color:#292d3e"><codeclass="codeBlockLines_39YC"><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">public static async Task Main()</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain">{</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> var config = SpotifyClientConfig</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .CreateDefault()</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .WithAuthenticator(new ClientCredentialsAuthenticator("CLIENT_ID", "CLIENT_SECRET"));</span></span><spanclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">