(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{168:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){returna})),n.d(t,"metadata",(function(){returnc})),n.d(t,"rightToc",(function(){returnl})),n.d(t,"default",(function(){returns}));varr=n(2),i=n(9),o=(n(0),n(188)),a={id:"configuration",title:"Configuration"},c={id:"configuration",title:"Configuration",description:"To configure the Spotify client functionality, the SpotifyClientConfig class exists.",source:"@site/docs/configuration.md",permalink:"/SpotifyAPI-NET/docs/next/configuration",editUrl:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/edit/master/SpotifyAPI.Docs/docs/configuration.md",version:"next",lastUpdatedBy:"dependabot[bot]",lastUpdatedAt:1617892807,sidebar:"docs",previous:{title:"Error Handling",permalink:"/SpotifyAPI-NET/docs/next/error_handling"},next:{title:"Logging",permalink:"/SpotifyAPI-NET/docs/next/logging"}},l=[{value:"HTTPClient Notes",id:"httpclient-notes",children:[]}],p={rightToc:l};functions(e){vart=e.components,n=Object(i.a)(e,["components"]);returnObject(o.b)("wrapper",Object(r.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("p",null,"To configure the Spotify client functionality, the ",Object(o.b)("inlineCode",{parentName:"p"},"SpotifyClientConfig")," class exists."),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-csharp"}),'var config = SpotifyClientConfig.CreateDefault("YourAccessToken");\nvar spotify = new SpotifyClient(config);\n\n// is the same as\n\nvar spotify = new SpotifyClient("YourAccessToken");\n')),Object(o.b)("p",null,"We won't cover every possible configuration in this part, head over to the specific guides for that:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"...")),Object(o.b)("h2",{id:"httpclient-notes"},"HTTPClient Notes"),Object(o.b)("p",null,"One important part of the configuration is the used HTTPClient. By default, every time a ",Object(o.b)("inlineCode",{parentName:"p"},"SpotifyClientConfig")," is instantiated, a new ",Object(o.b)("inlineCode",{parentName:"p"},"HTTPClient")," is created in the background. For Web Applications that require a lot of different configs due to user based access tokens, it is ",Object(o.b)("strong",{parentName:"p"},"not")," advised to create a new config from scratch with every HTTP call. Instead, a default (static) config should be used to create a new config with a new access token."),Object(o.b)("p",null,"Consider the following HTTP Endpoint:"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-csharp"}),'public HttpResult Get()\n{\n var config = SpotifyClientConfig.CreateDefault("YourAccessToken")\n var spotify = new SpotifyClient(config);\n}\n')),Object(o.b)("p",null,"This creates a new ",Object(o.b)("inlineCode",{parentName:"p"},"HTTPClient")," every time a request is made, which can be quite bad for the performance. Instead, we should use a base config and use ",Object(o.b)("inlineCode",{parentName:"p"},"WithToken"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-csharp"}),'// somewhere global/static\npublic static SpotifyClientConfig DefaultConfig = SpotifyClientConfig.CreateDefault();\n\npublic HttpResult Get()\n{\n var config = DefaultConfig.WithToken("YourAccessToken");\n var spotify = new SpotifyClient(config);\n}\n')),Object(o.b)("p",null,"This way, a single ",Object(o.b)("inlineCode",{parentName:"p"},"HTTPClient")," will be used. For a real example, checkout the ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"/SpotifyAPI-NET/docs/next/example_asp"}),"ASP.NET Example"),"."))}s.isMDXComponent=!0},188:function(e,t,n){"use strict";n.d(t,"a",(function(){returnf})),n.d(t,"b",(function(){returnd}));varr=n(0),i=n.n(r);functiono(e,t,n){returntine?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}functiona(e,t){varn=Object.keys(e);if(Object.getOwnPropertySymbols){varr=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){retu