Spotify.NET/293befc8.957dbc3f.js
2020-06-04 16:12:54 +02:00

1 line
4.9 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{117:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return i})),r.d(t,"metadata",(function(){return c})),r.d(t,"rightToc",(function(){return p})),r.d(t,"default",(function(){return l}));var n=r(2),a=r(6),o=(r(0),r(151)),i={id:"example_asp",title:"ASP.NET"},c={id:"example_asp",title:"ASP.NET",description:"Description",source:"@site/docs/example_asp.md",permalink:"/docs/next/example_asp",editUrl:"https://github.com/JohnnyCrazy/SpotifyAPI-NET/edit/master/SpotifyAPI.Docs/docs/example_asp.md",version:"next",lastUpdatedBy:"Jonas Dellinger",lastUpdatedAt:1591277053,sidebar:"docs",previous:{title:"Showcase",permalink:"/docs/next/showcase"},next:{title:"Blazor WASM",permalink:"/docs/next/example_blazor_wasm"}},p=[{value:"Description",id:"description",children:[]},{value:"Run it",id:"run-it",children:[]}],s={rightToc:p};function l(e){var t=e.components,r=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(n.a)({},s,r,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"description"},"Description"),Object(o.b)("p",null,"This example is based on ASP .NET Core. It uses ",Object(o.b)("inlineCode",{parentName:"p"},"Authorization Code")," under the hood with the help of ",Object(o.b)("a",Object(n.a)({parentName:"p"},{href:"https://www.nuget.org/packages/AspNet.Security.OAuth.Spotify/"}),Object(o.b)("inlineCode",{parentName:"a"},"AspNet.Security.OAuth.Spotify")),". It stores the access token in the current user session (cookie-based) and allows to refresh tokens when they expire. Two pages are implemented:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"Home shows your current playlists via pagination"),Object(o.b)("li",{parentName:"ul"},"Profile shows your current profile information")),Object(o.b)("p",null,Object(o.b)("img",Object(n.a)({parentName:"p"},{src:"/img/asp_example_home.png",alt:"ASP Example - Home"})),"\n",Object(o.b)("img",Object(n.a)({parentName:"p"},{src:"/img/asp_example_profile.png",alt:"ASP Example - Profile"}))),Object(o.b)("h2",{id:"run-it"},"Run it"),Object(o.b)("p",null,"Before running it, make sure you created an app in your ",Object(o.b)("a",Object(n.a)({parentName:"p"},{href:"https://developer.spotify.com/dashboard/"}),"spotify dashboard")," and ",Object(o.b)("inlineCode",{parentName:"p"},"https://localhost:5001")," is a redirect uri of it."),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-bash"}),"# Assumes linux and current working directory is the cloned repository\ncd SpotifyAPI.Web.Examples/Example.ASP\ndotnet restore\n\nSPOTIFY_CLIENT_ID=YourClientId SPOTIFY_CLIENT_SECRET=YourClientSecret dotnet run\n\n# Visit https://localhost:5001\n")))}l.isMDXComponent=!0},151:function(e,t,r){"use strict";r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return m}));var n=r(0),a=r.n(n);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function p(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var s=a.a.createContext({}),l=function(e){var t=a.a.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):c({},t,{},e)),r},u=function(e){var t=l(e.components);return a.a.createElement(s.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},d=Object(n.forwardRef)((function(e,t){var r=e.components,n=e.mdxType,o=e.originalType,i=e.parentName,s=p(e,["components","mdxType","originalType","parentName"]),u=l(r),d=n,m=u["".concat(i,".").concat(d)]||u[d]||b[d]||o;return r?a.a.createElement(m,c({ref:t},s,{components:r})):a.a.createElement(m,c({ref:t},s))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var o=r.length,i=new Array(o);i[0]=d;var c={};for(var p in t)hasOwnProperty.call(t,p)&&(c[p]=t[p]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var s=2;s<o;s++)i[s]=r[s];return a.a.createElement.apply(null,i)}return a.a.createElement.apply(null,r)}d.displayName="MDXCreateElement"}}]);