[
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2012-2016 Spotify AB\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Spotify Web API Examples\n\n## Contents\n\n- Authorization examples\n    - [Authorization Code]( /authorization/authorization_code/)\n    - [Authorization Code with PKCE extension]( /authorization/authorization_code_pkce/)\n    - [Client Credentials](/authorization/client_credentials)\n    - [Implicit Grant](/authorization/implicit_grant/)\n- [Get User Profile example](/get_user_profile/)\n"
  },
  {
    "path": "authorization/.gitignore",
    "content": "node_modules/\n"
  },
  {
    "path": "authorization/authorization_code/README.md",
    "content": "# Spotify Authorization Code example\n\nThis app displays your Spotify profile information using [Authorization Code](https://developer.spotify.com/documentation/web-api/tutorials/code-flow)\nto grant permissions to the app.\n\n## Installation\n\nThis example runs on Node.js. On [its website](http://www.nodejs.org/download/) you can find instructions on how to install it.\n\nInstall the app dependencies running:\n\n    $ npm install\n\n## Using your own credentials\n\nYou will need to register your app and get your own credentials from the [Spotify for Developers Dashboard](https://developer.spotify.com/dashboard).\n\n- Create a new app in the dashboard and add `http://localhost:8888/callback` to the app's redirect URL list.\n- Once you have created your app, update the `client_id`, `redirect_uri`, and `client_secret` in the `app.js` file with the credentials obtained from the app settings in the dashboard.\n\n## Running the example\n\nFrom a console shell:\n\n    $ npm start\n\nThen, open `http://localhost:8888` in a browser.\n"
  },
  {
    "path": "authorization/authorization_code/app.js",
    "content": "/**\n * This is an example of a basic node.js script that performs\n * the Authorization Code oAuth2 flow to authenticate against\n * the Spotify Accounts.\n *\n * For more information, read\n * https://developer.spotify.com/documentation/web-api/tutorials/code-flow\n */\n\nvar express = require('express');\nvar request = require('request');\nvar crypto = require('crypto');\nvar cors = require('cors');\nvar querystring = require('querystring');\nvar cookieParser = require('cookie-parser');\n\nvar client_id = 'yourClientIDGoesHere'; // your clientId\nvar client_secret = 'YourSecretIDGoesHere'; // Your secret\nvar redirect_uri = 'http://localhost:8888/callback'; // Your redirect uri\n\n\nconst generateRandomString = (length) => {\n  return crypto\n  .randomBytes(60)\n  .toString('hex')\n  .slice(0, length);\n}\n\nvar stateKey = 'spotify_auth_state';\n\nvar app = express();\n\napp.use(express.static(__dirname + '/public'))\n   .use(cors())\n   .use(cookieParser());\n\napp.get('/login', function(req, res) {\n\n  var state = generateRandomString(16);\n  res.cookie(stateKey, state);\n\n  // your application requests authorization\n  var scope = 'user-read-private user-read-email';\n  res.redirect('https://accounts.spotify.com/authorize?' +\n    querystring.stringify({\n      response_type: 'code',\n      client_id: client_id,\n      scope: scope,\n      redirect_uri: redirect_uri,\n      state: state\n    }));\n});\n\napp.get('/callback', function(req, res) {\n\n  // your application requests refresh and access tokens\n  // after checking the state parameter\n\n  var code = req.query.code || null;\n  var state = req.query.state || null;\n  var storedState = req.cookies ? req.cookies[stateKey] : null;\n\n  if (state === null || state !== storedState) {\n    res.redirect('/#' +\n      querystring.stringify({\n        error: 'state_mismatch'\n      }));\n  } else {\n    res.clearCookie(stateKey);\n    var authOptions = {\n      url: 'https://accounts.spotify.com/api/token',\n      form: {\n        code: code,\n        redirect_uri: redirect_uri,\n        grant_type: 'authorization_code'\n      },\n      headers: {\n        'content-type': 'application/x-www-form-urlencoded',\n        Authorization: 'Basic ' + (new Buffer.from(client_id + ':' + client_secret).toString('base64'))\n      },\n      json: true\n    };\n\n    request.post(authOptions, function(error, response, body) {\n      if (!error && response.statusCode === 200) {\n\n        var access_token = body.access_token,\n            refresh_token = body.refresh_token;\n\n        var options = {\n          url: 'https://api.spotify.com/v1/me',\n          headers: { 'Authorization': 'Bearer ' + access_token },\n          json: true\n        };\n\n        // use the access token to access the Spotify Web API\n        request.get(options, function(error, response, body) {\n          console.log(body);\n        });\n\n        // we can also pass the token to the browser to make requests from there\n        res.redirect('/#' +\n          querystring.stringify({\n            access_token: access_token,\n            refresh_token: refresh_token\n          }));\n      } else {\n        res.redirect('/#' +\n          querystring.stringify({\n            error: 'invalid_token'\n          }));\n      }\n    });\n  }\n});\n\napp.get('/refresh_token', function(req, res) {\n\n  var refresh_token = req.query.refresh_token;\n  var authOptions = {\n    url: 'https://accounts.spotify.com/api/token',\n    headers: { \n      'content-type': 'application/x-www-form-urlencoded',\n      'Authorization': 'Basic ' + (new Buffer.from(client_id + ':' + client_secret).toString('base64')) \n    },\n    form: {\n      grant_type: 'refresh_token',\n      refresh_token: refresh_token\n    },\n    json: true\n  };\n\n  request.post(authOptions, function(error, response, body) {\n    if (!error && response.statusCode === 200) {\n      var access_token = body.access_token,\n          refresh_token = body.refresh_token;\n      res.send({\n        'access_token': access_token,\n        'refresh_token': refresh_token\n      });\n    }\n  });\n});\n\nconsole.log('Listening on 8888');\napp.listen(8888);\n"
  },
  {
    "path": "authorization/authorization_code/package.json",
    "content": "{\n  \"name\": \"spotify-authorization-code-example\",\n  \"version\": \"0.0.2\",\n  \"description\": \"Spotify Authorization Code flow example\",\n  \"author\": \"Spotify\",\n  \"scripts\": {\n    \"start\": \"node app.js\"\n  },\n  \"dependencies\": {\n    \"cookie-parser\": \"1.4.6\",\n    \"cors\": \"2.8.5\",\n    \"express\": \"4.18.2\",\n    \"querystring\": \"~0.2.0\",\n    \"request\": \"2.88.2\"\n  }\n}\n"
  },
  {
    "path": "authorization/authorization_code/public/index.html",
    "content": "<!doctype html>\n<html>\n  <head>\n    <title>Example of the Authorization Code flow with Spotify</title>\n    <link rel=\"stylesheet\" href=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css\">\n    <style type=\"text/css\">\n      #login, #loggedin {\n        display: none;\n      }\n      .text-overflow {\n        overflow: hidden;\n        text-overflow: ellipsis;\n        white-space: nowrap;\n        width: 500px;\n      }\n    </style>\n  </head>\n\n  <body>\n    <div class=\"container\">\n      <div id=\"login\">\n        <h1>This is an example of the Authorization Code flow</h1>\n        <a href=\"/login\" class=\"btn btn-primary\">Log in with Spotify</a>\n      </div>\n      <div id=\"loggedin\">\n        <div id=\"user-profile\">\n        </div>\n        <div id=\"oauth\">\n        </div>\n        <button class=\"btn btn-default\" id=\"obtain-new-token\">Obtain new token using the refresh token</button>\n      </div>\n    </div>\n\n    <script id=\"user-profile-template\" type=\"text/x-handlebars-template\">\n      <h1>Logged in as {{display_name}}</h1>\n      <div class=\"media\">\n        <div class=\"pull-left\">\n          <img class=\"media-object\" width=\"150\" src=\"{{images.0.url}}\" />\n        </div>\n        <div class=\"media-body\">\n          <dl class=\"dl-horizontal\">\n            <dt>Display name</dt><dd class=\"clearfix\">{{display_name}}</dd>\n            <dt>Id</dt><dd>{{id}}</dd>\n            <dt>Email</dt><dd>{{email}}</dd>\n            <dt>Spotify URI</dt><dd><a href=\"{{external_urls.spotify}}\">{{external_urls.spotify}}</a></dd>\n            <dt>Link</dt><dd><a href=\"{{href}}\">{{href}}</a></dd>\n            <dt>Profile Image</dt><dd class=\"clearfix\"><a href=\"{{images.0.url}}\">{{images.0.url}}</a></dd>\n            <dt>Country</dt><dd>{{country}}</dd>\n          </dl>\n        </div>\n      </div>\n    </script>\n\n    <script id=\"oauth-template\" type=\"text/x-handlebars-template\">\n      <h2>oAuth info</h2>\n      <dl class=\"dl-horizontal\">\n        <dt>Access token</dt><dd class=\"text-overflow\">{{access_token}}</dd>\n        <dt>Refresh token</dt><dd class=\"text-overflow\">{{refresh_token}}</dd>\n      </dl>\n    </script>\n\n    <script src=\"//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js\"></script>\n    <script src=\"http://code.jquery.com/jquery-1.10.1.min.js\"></script>\n    <script>\n      (function() {\n\n        /**\n         * Obtains parameters from the hash of the URL\n         * @return Object\n         */\n        function getHashParams() {\n          var hashParams = {};\n          var e, r = /([^&;=]+)=?([^&;]*)/g,\n              q = window.location.hash.substring(1);\n          while ( e = r.exec(q)) {\n             hashParams[e[1]] = decodeURIComponent(e[2]);\n          }\n          return hashParams;\n        }\n\n        var userProfileSource = document.getElementById('user-profile-template').innerHTML,\n            userProfileTemplate = Handlebars.compile(userProfileSource),\n            userProfilePlaceholder = document.getElementById('user-profile');\n\n        var oauthSource = document.getElementById('oauth-template').innerHTML,\n            oauthTemplate = Handlebars.compile(oauthSource),\n            oauthPlaceholder = document.getElementById('oauth');\n\n        var params = getHashParams();\n\n        var access_token = params.access_token,\n            refresh_token = params.refresh_token,\n            error = params.error;\n\n        if (error) {\n          alert('There was an error during the authentication');\n        } else {\n          if (access_token) {\n            // render oauth info\n            oauthPlaceholder.innerHTML = oauthTemplate({\n              access_token: access_token,\n              refresh_token: refresh_token\n            });\n\n            $.ajax({\n                url: 'https://api.spotify.com/v1/me',\n                headers: {\n                  'Authorization': 'Bearer ' + access_token\n                },\n                success: function(response) {\n                  userProfilePlaceholder.innerHTML = userProfileTemplate(response);\n\n                  $('#login').hide();\n                  $('#loggedin').show();\n                }\n            });\n          } else {\n              // render initial screen\n              $('#login').show();\n              $('#loggedin').hide();\n          }\n\n          document.getElementById('obtain-new-token').addEventListener('click', function() {\n            $.ajax({\n              url: '/refresh_token',\n              data: {\n                'refresh_token': refresh_token\n              }\n            }).done(function(data) {\n              access_token = data.access_token;\n              oauthPlaceholder.innerHTML = oauthTemplate({\n                access_token: access_token,\n                refresh_token: refresh_token\n              });\n            });\n          }, false);\n        }\n      })();\n    </script>\n  </body>\n</html>\n\n"
  },
  {
    "path": "authorization/authorization_code_pkce/README.md",
    "content": "# Spotify Authorization Code with PKCE example\n\nThis app displays your Spotify profile information using [Authorization Code with PKCE](https://developer.spotify.com/documentation/web-api/tutorials/code-pkce-flow)\nto grant permissions to the app.\n\n## Using your own credentials\n\nYou will need to register your app and get your own credentials from the [Spotify for Developers Dashboard](https://developer.spotify.com/dashboard).\n\n- Create a new app in the dashboard and add `http://localhost:8080` to the app's redirect URL list.\n- Once you have created your app, update the `client_id` and `redirect_uri` in the `public/app.js` file with the values obtained from the app settings in the dashboard.\n\n## Running the example\n\nFrom a console shell:\n\n    $ npm start\n\nThen, open `http://localhost:8080` in a browser.\n"
  },
  {
    "path": "authorization/authorization_code_pkce/package.json",
    "content": "{\n  \"name\": \"spotify-authorization-code-pkce\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Spotify Authorization Code with PKCE flow example\",\n  \"scripts\": {\n    \"start\": \"http-server --cors public\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"http-server\": \"^14.1.1\"\n  }\n}\n"
  },
  {
    "path": "authorization/authorization_code_pkce/public/app.js",
    "content": "/**\n * This is an example of a basic node.js script that performs\n * the Authorization Code with PKCE oAuth2 flow to authenticate \n * against the Spotify Accounts.\n *\n * For more information, read\n * https://developer.spotify.com/documentation/web-api/tutorials/code-pkce-flow\n */\n\nconst clientId = 'yourClientIDGoesHere'; // your clientId\nconst redirectUrl = 'eg:http://localhost:8080';        // your redirect URL - must be localhost URL and/or HTTPS\n\nconst authorizationEndpoint = \"https://accounts.spotify.com/authorize\";\nconst tokenEndpoint = \"https://accounts.spotify.com/api/token\";\nconst scope = 'user-read-private user-read-email';\n\n// Data structure that manages the current active token, caching it in localStorage\nconst currentToken = {\n  get access_token() { return localStorage.getItem('access_token') || null; },\n  get refresh_token() { return localStorage.getItem('refresh_token') || null; },\n  get expires_in() { return localStorage.getItem('refresh_in') || null },\n  get expires() { return localStorage.getItem('expires') || null },\n\n  save: function (response) {\n    const { access_token, refresh_token, expires_in } = response;\n    localStorage.setItem('access_token', access_token);\n    localStorage.setItem('refresh_token', refresh_token);\n    localStorage.setItem('expires_in', expires_in);\n\n    const now = new Date();\n    const expiry = new Date(now.getTime() + (expires_in * 1000));\n    localStorage.setItem('expires', expiry);\n  }\n};\n\n// On page load, try to fetch auth code from current browser search URL\nconst args = new URLSearchParams(window.location.search);\nconst code = args.get('code');\n\n// If we find a code, we're in a callback, do a token exchange\nif (code) {\n  const token = await getToken(code);\n  currentToken.save(token);\n\n  // Remove code from URL so we can refresh correctly.\n  const url = new URL(window.location.href);\n  url.searchParams.delete(\"code\");\n\n  const updatedUrl = url.search ? url.href : url.href.replace('?', '');\n  window.history.replaceState({}, document.title, updatedUrl);\n}\n\n// If we have a token, we're logged in, so fetch user data and render logged in template\nif (currentToken.access_token) {\n  const userData = await getUserData();\n  renderTemplate(\"main\", \"logged-in-template\", userData);\n  renderTemplate(\"oauth\", \"oauth-template\", currentToken);\n}\n\n// Otherwise we're not logged in, so render the login template\nif (!currentToken.access_token) {\n  renderTemplate(\"main\", \"login\");\n}\n\nasync function redirectToSpotifyAuthorize() {\n  const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n  const randomValues = crypto.getRandomValues(new Uint8Array(64));\n  const randomString = randomValues.reduce((acc, x) => acc + possible[x % possible.length], \"\");\n\n  const code_verifier = randomString;\n  const data = new TextEncoder().encode(code_verifier);\n  const hashed = await crypto.subtle.digest('SHA-256', data);\n\n  const code_challenge_base64 = btoa(String.fromCharCode(...new Uint8Array(hashed)))\n    .replace(/=/g, '')\n    .replace(/\\+/g, '-')\n    .replace(/\\//g, '_');\n\n  window.localStorage.setItem('code_verifier', code_verifier);\n\n  const authUrl = new URL(authorizationEndpoint)\n  const params = {\n    response_type: 'code',\n    client_id: clientId,\n    scope: scope,\n    code_challenge_method: 'S256',\n    code_challenge: code_challenge_base64,\n    redirect_uri: redirectUrl,\n  };\n\n  authUrl.search = new URLSearchParams(params).toString();\n  window.location.href = authUrl.toString(); // Redirect the user to the authorization server for login\n}\n\n// Soptify API Calls\nasync function getToken(code) {\n  const code_verifier = localStorage.getItem('code_verifier');\n\n  const response = await fetch(tokenEndpoint, {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded',\n    },\n    body: new URLSearchParams({\n      client_id: clientId,\n      grant_type: 'authorization_code',\n      code: code,\n      redirect_uri: redirectUrl,\n      code_verifier: code_verifier,\n    }),\n  });\n\n  return await response.json();\n}\n\nasync function refreshToken() {\n  const response = await fetch(tokenEndpoint, {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded'\n    },\n    body: new URLSearchParams({\n      client_id: clientId,\n      grant_type: 'refresh_token',\n      refresh_token: currentToken.refresh_token\n    }),\n  });\n\n  return await response.json();\n}\n\nasync function getUserData() {\n  const response = await fetch(\"https://api.spotify.com/v1/me\", {\n    method: 'GET',\n    headers: { 'Authorization': 'Bearer ' + currentToken.access_token },\n  });\n\n  return await response.json();\n}\n\n// Click handlers\nasync function loginWithSpotifyClick() {\n  await redirectToSpotifyAuthorize();\n}\n\nasync function logoutClick() {\n  localStorage.clear();\n  window.location.href = redirectUrl;\n}\n\nasync function refreshTokenClick() {\n  const token = await refreshToken();\n  currentToken.save(token);\n  renderTemplate(\"oauth\", \"oauth-template\", currentToken);\n}\n\n// HTML Template Rendering with basic data binding - demoware only.\nfunction renderTemplate(targetId, templateId, data = null) {\n  const template = document.getElementById(templateId);\n  const clone = template.content.cloneNode(true);\n\n  const elements = clone.querySelectorAll(\"*\");\n  elements.forEach(ele => {\n    const bindingAttrs = [...ele.attributes].filter(a => a.name.startsWith(\"data-bind\"));\n\n    bindingAttrs.forEach(attr => {\n      const target = attr.name.replace(/data-bind-/, \"\").replace(/data-bind/, \"\");\n      const targetType = target.startsWith(\"onclick\") ? \"HANDLER\" : \"PROPERTY\";\n      const targetProp = target === \"\" ? \"innerHTML\" : target;\n\n      const prefix = targetType === \"PROPERTY\" ? \"data.\" : \"\";\n      const expression = prefix + attr.value.replace(/;\\n\\r\\n/g, \"\");\n\n      // Maybe use a framework with more validation here ;)\n      try {\n        ele[targetProp] = targetType === \"PROPERTY\" ? eval(expression) : () => { eval(expression) };\n        ele.removeAttribute(attr.name);\n      } catch (ex) {\n        console.error(`Error binding ${expression} to ${targetProp}`, ex);\n      }\n    });\n  });\n\n  const target = document.getElementById(targetId);\n  target.innerHTML = \"\";\n  target.appendChild(clone);\n}\n"
  },
  {
    "path": "authorization/authorization_code_pkce/public/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n  <title>Example of the Authorization Code with PKCE flow with Spotify</title>\n  <link rel=\"stylesheet\" href=\"style.css\">\n</head>\n\n<body>\n\n  <div id=\"main\"></div>\n  <div id=\"oauth\"></div>\n\n  <template id=\"login\">\n    <h1>Welcome to the OAuth2 PKCE Example</h1>\n    <button id=\"login-button\" data-bind-onclick=\"loginWithSpotifyClick();\"> Log in with Spotify </button>\n  </template>\n\n  <template id=\"logged-in-template\">\n    <h1>Logged in as <span data-bind=\"display_name\"></span></h1>\n    <img width=\"150\" data-bind-src=\"images[0].url\" data-bind-alt=\"display_name\" />\n    <table>\n      <tr>\n        <td>Display name</td>\n        <td data-bind=\"display_name\"></td>\n      </tr>\n      <tr>\n        <td>Id</td>\n        <td data-bind=\"id\"></td>\n      </tr>\n      <tr>\n        <td>Email</td>\n        <td data-bind=\"email\"></td>\n      </tr>\n      <tr>\n        <td>Spotify URI</td>\n        <td>\n          <a data-bind=\"external_urls.spotify\" data-bind-href=\"external_urls.spotify\"></a>\n        </td>\n      </tr>\n      <tr>\n        <td>Link </dt>\n        <td>\n          <a data-bind=\"href\" data-bind-href=\"href\"></a>\n        </td>\n      </tr>\n      <tr>\n        <td>Profile Image</td>\n        <td>\n          <a data-bind-href=\"images[0].url\" data-bind=\"images[0].url\"></a>\n        </td>\n      </tr>\n      <tr>\n        <td>Country</td>\n        <td data-bind=\"country\"></td>\n      </tr>\n    </table>\n\n    <button id=\"refresh-token-button\" data-bind-onclick=\"refreshTokenClick();\">Refresh Token</button>\n    <button id=\"logout-button\" data-bind-onclick=\"logoutClick();\">Log out</button>\n  </template>\n\n  <template id=\"oauth-template\">\n    <h2>oAuth info</h2>\n    <table>\n      <tr>\n        <td>Access token</td>\n        <td data-bind=\"access_token\"></td>\n      </tr>\n      <tr>\n        <td>Refresh token</td>\n        <td data-bind=\"refresh_token\"></td>\n      </tr>\n      <tr>\n        <td>Expiration at</td>\n        <td data-bind=\"expires\">${getExpirationDate(expires_in)}</td>\n      </tr>\n    </table>\n  </template>\n\n  <script src=\"app.js\" type=\"module\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "authorization/authorization_code_pkce/public/style.css",
    "content": "body {\n    margin: 1rem;\n    font-family: Arial, Helvetica, sans-serif;\n}\n\ntr:nth-child(even) {\n    background-color: #eee;\n}\n\ntd:first-child {\n    font-weight: bold;\n}\n\ntd {\n    white-space: nowrap;\n    padding: 10px;\n    margin-right: 1rem;\n}\n\nbutton {\n    margin: 1rem 1rem 0 0;\n    border: 0;\n    border-radius: 20px;\n    padding: 10px 3rem;\n    font-size: 0.8rem;\n    font-family: Arial, Helvetica, sans-serif;\n    text-transform: uppercase;\n    font-weight: bold;\n    background-color:#1ed760;\n    color: black;\n}\n\nbutton:hover {\n    background-color: #1fdf64;\n}\n\n#logged-in {\n    display: none;\n}\n"
  },
  {
    "path": "authorization/catalog-info.yaml",
    "content": "apiVersion: backstage.io/v1alpha1\nkind: Component\nmetadata:\n  name: web-api-auth-examples\nspec:\n  type: library\n  owner: opx-partner-activation\n"
  },
  {
    "path": "authorization/client_credentials/README.md",
    "content": "# Spotify Client Credentials example\n\nThis app retrieves information from an artist's track using [Client Credentials](https://developer.spotify.com/documentation/web-api/tutorials/code-flow)\nto grant permissions to the app.\n\n## Installation\n\nThis example runs on Node.js. On [its website](http://www.nodejs.org/download/) you can find instructions on how to install it.\n\n### Using your own credentials\n\nYou will need to register your app and get your own credentials from the [Spotify for Developers Dashboard](https://developer.spotify.com/dashboard).\n\n- Create a new app in the dashboard and add `http://localhost:8888/callback` to the app's redirect URL list.\n- Once you have created your app, update the `client_id` and `client_secret` in the `app.js` file with the credentials obtained from the app settings in the dashboard.\n\n## Running the example\n\nFrom a console shell:\n\n    $ node app.js\n"
  },
  {
    "path": "authorization/client_credentials/app.js",
    "content": "/**\n * This is an example of a basic node.js script that performs\n * the Client Credentials oAuth2 flow to authenticate against\n * the Spotify Accounts.\n *\n * For more information, read\n * https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow\n */\n\nconst client_id = 'YourClientId'; \nconst client_secret = 'YourClientSecret';\n\nasync function getToken() {\n  const response = await fetch('https://accounts.spotify.com/api/token', {\n    method: 'POST',\n    body: new URLSearchParams({\n      'grant_type': 'client_credentials',\n    }),\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded',\n      'Authorization': 'Basic ' + (Buffer.from(client_id + ':' + client_secret).toString('base64')),\n    },\n  });\n\n  return await response.json();\n}\n\nasync function getTrackInfo(access_token) {\n  const response = await fetch(\"https://api.spotify.com/v1/tracks/4cOdK2wGLETKBW3PvgPWqT\", {\n    method: 'GET',\n    headers: { 'Authorization': 'Bearer ' + access_token },\n  });\n\n  return await response.json();\n}\n\ngetToken().then(response => {\n  getTrackInfo(response.access_token).then(profile => {\n    console.log(profile)\n  })\n});\n"
  },
  {
    "path": "authorization/implicit_grant/README.md",
    "content": "# Spotify Implicit Grant example\n\nThis app displays your Spotify profile information using [Implicit Grant](https://developer.spotify.com/documentation/web-api/tutorials/implicit-flow)\nto grant permissions to the app.\n\n> The implicit grant flow has some significant security flaws, so we strongly advise against using this flow. If you need to implement authorization where storing your client secret is not possible, use Authorization code with PKCE instead.\n\n## Installation\n\nThis example runs on Node.js. On [its website](http://www.nodejs.org/download/) you can find instructions on how to install it.\n\nInstall the app dependencies running:\n\n    $ npm install\n\n## Using your own credentials\n\nYou will need to register your app and get your own credentials from the [Spotify for Developers Dashboard](https://developer.spotify.com/dashboard).\n\n- Create a new app in the dashboard and add `http://localhost:8080` to the app's redirect URL list.\n- Once you have created your app, update the `client_id` and `redirect_uri` in the `public/index.html` file with the values obtained from the app settings in the dashboard.\n\n## Running the example\n\nFrom a console shell:\n\n    $ npm start\n\nThen, open `http://localhost:8080` in a browser.\n"
  },
  {
    "path": "authorization/implicit_grant/app.js",
    "content": "/**\n * This is an example of a basic node.js script that performs\n * the Implicit Grant oAuth2 flow to authenticate against\n * the Spotify Accounts.\n *\n * For more information, read\n * https://developer.spotify.com/documentation/web-api/tutorials/implicit-flow\n */\n\nvar express = require('express'); // Express web server framework\nvar app = express();\napp.use(express.static(__dirname + '/public'));\nconsole.log('Listening on 8888');\napp.listen(8888);\n"
  },
  {
    "path": "authorization/implicit_grant/package.json",
    "content": "{\n  \"name\": \"spotify-implicit-grant-example\",\n  \"version\": \"0.0.2\",\n  \"description\": \"Spotify Implicit Grant example\",\n  \"author\": \"Spotify\",\n  \"scripts\": {\n    \"start\": \"node app.js\"\n  },\n  \"dependencies\": {\n    \"express\": \"4.18.2\"\n  }\n}\n"
  },
  {
    "path": "authorization/implicit_grant/public/index.html",
    "content": "<!doctype html>\n<html>\n  <head>\n    <title>Example of the Implicit Grant flow with Spotify</title>\n    <link rel=\"stylesheet\" href=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css\">\n    <style type=\"text/css\">\n      #login, #loggedin {\n        display: none;\n      }\n      .text-overflow {\n        overflow: hidden;\n        text-overflow: ellipsis;\n        white-space: nowrap;\n        width: 500px;\n      }\n    </style>\n  </head>\n\n  <body>\n    <div class=\"container\">\n      <div id=\"login\">\n        <h1>This is an example of the Implicit Grant flow</h1>\n        <button id=\"login-button\" class=\"btn btn-primary\">Log in with Spotify</button>\n      </div>\n      <div id=\"loggedin\">\n        <div id=\"user-profile\">\n        </div>\n        <div id=\"oauth\">\n        </div>\n      </div>\n    </div>\n\n    <script id=\"user-profile-template\" type=\"text/x-handlebars-template\">\n      <h1>Logged in as {{display_name}}</h1>\n      <div class=\"media\">\n        <div class=\"pull-left\">\n          <img class=\"media-object\" width=\"150\" src=\"{{images.0.url}}\" />\n        </div>\n        <div class=\"media-body\">\n          <dl class=\"dl-horizontal\">\n            <dt>Display name</dt><dd class=\"clearfix\">{{display_name}}</dd>\n            <dt>Id</dt><dd>{{id}}</dd>\n            <dt>Email</dt><dd>{{email}}</dd>\n            <dt>Spotify URI</dt><dd><a href=\"{{external_urls.spotify}}\">{{external_urls.spotify}}</a></dd>\n            <dt>Link</dt><dd><a href=\"{{href}}\">{{href}}</a></dd>\n            <dt>Profile Image</dt><dd class=\"clearfix\"><a href=\"{{images.0.url}}\">{{images.0.url}}</a></dd>\n            <dt>Country</dt><dd>{{country}}</dd>\n          </dl>\n        </div>\n      </div>\n    </script>\n\n    <script id=\"oauth-template\" type=\"text/x-handlebars-template\">\n      <h2>oAuth info</h2>\n      <dl class=\"dl-horizontal\">\n        <dt>Access token</dt><dd class=\"text-overflow\">{{access_token}}</dd>\n      </dl>\n    </script>\n\n    <script src=\"//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js\"></script>\n    <script src=\"http://code.jquery.com/jquery-1.10.1.min.js\"></script>\n    <script>\n      (function() {\n\n        var stateKey = 'spotify_auth_state';\n\n        /**\n         * Obtains parameters from the hash of the URL\n         * @return Object\n         */\n        function getHashParams() {\n          var hashParams = {};\n          var e, r = /([^&;=]+)=?([^&;]*)/g,\n              q = window.location.hash.substring(1);\n          while ( e = r.exec(q)) {\n             hashParams[e[1]] = decodeURIComponent(e[2]);\n          }\n          return hashParams;\n        }\n\n        /**\n         * Generates a random string containing numbers and letters\n         * @param  {number} length The length of the string\n         * @return {string} The generated string\n         */\n        function generateRandomString(length) {\n          var text = '';\n          var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n          for (var i = 0; i < length; i++) {\n            text += possible.charAt(Math.floor(Math.random() * possible.length));\n          }\n          return text;\n        };\n\n        var userProfileSource = document.getElementById('user-profile-template').innerHTML,\n            userProfileTemplate = Handlebars.compile(userProfileSource),\n            userProfilePlaceholder = document.getElementById('user-profile');\n\n            oauthSource = document.getElementById('oauth-template').innerHTML,\n            oauthTemplate = Handlebars.compile(oauthSource),\n            oauthPlaceholder = document.getElementById('oauth');\n\n        var params = getHashParams();\n\n        var access_token = params.access_token,\n            state = params.state,\n            storedState = localStorage.getItem(stateKey);\n\n        if (access_token && (state == null || state !== storedState)) {\n          alert('There was an error during the authentication');\n        } else {\n          localStorage.removeItem(stateKey);\n          if (access_token) {\n            $.ajax({\n                url: 'https://api.spotify.com/v1/me',\n                headers: {\n                  'Authorization': 'Bearer ' + access_token\n                },\n                success: function(response) {\n                  userProfilePlaceholder.innerHTML = userProfileTemplate(response);\n\n                  $('#login').hide();\n                  $('#loggedin').show();\n                }\n            });\n          } else {\n              $('#login').show();\n              $('#loggedin').hide();\n          }\n\n          document.getElementById('login-button').addEventListener('click', function() {\n\n            var client_id = 'CLIENT_ID'; // Your client id\n            var redirect_uri = 'REDIRECT_URI'; // Your redirect uri\n\n            var state = generateRandomString(16);\n\n            localStorage.setItem(stateKey, state);\n            var scope = 'user-read-private user-read-email';\n\n            var url = 'https://accounts.spotify.com/authorize';\n            url += '?response_type=token';\n            url += '&client_id=' + encodeURIComponent(client_id);\n            url += '&scope=' + encodeURIComponent(scope);\n            url += '&redirect_uri=' + encodeURIComponent(redirect_uri);\n            url += '&state=' + encodeURIComponent(state);\n\n            window.location = url;\n          }, false);\n        }\n      })();\n    </script>\n</html>\n"
  },
  {
    "path": "catalog-info.yaml",
    "content": "apiVersion: backstage.io/v1alpha1\nkind: Component\nmetadata:\n  name: web-api-auth-examples\nspec:\n  type: library\n  owner: opx-partner-activation\n"
  },
  {
    "path": "get_user_profile/.gitignore",
    "content": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\nlerna-debug.log*\n\nnode_modules\ndist\ndist-ssr\n*.local\n\n# Editor directories and files\n.vscode/*\n!.vscode/extensions.json\n.idea\n.DS_Store\n*.suo\n*.ntvs*\n*.njsproj\n*.sln\n*.sw?\n"
  },
  {
    "path": "get_user_profile/README.md",
    "content": "\n# Display your Spotify Profile Data in a Web App\n\nThis is the final code for the Spotify Web API - How to Display your Profile Data in a Web . You can run this demo directly or [walk through the tutorial](https://developer.spotify.com/documentation/web-api/howtos/web-app-profile).\n\n## Pre-requisites\n\nTo run this demo you will need:\n\n- A [Node.js LTS](https://nodejs.org/en/) environment or later.\n- A [Spotify Developer Account](https://developer.spotify.com/)\n\n## Usage\n\nCreate an app in your [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/), set the redirect URI to ` http://localhost:5173/callback` and `http://localhost:5173/callback/` and copy your Client ID. \n\nClone the repository, ensure that you are in the `get_user_profile` directory and run:\n\n```bash\nnpm install\nnpm run dev\n```\n\nReplace the value for clientId in `/src/script.ts` with your own Client ID.\n"
  },
  {
    "path": "get_user_profile/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <title>Example</title>\n  <script src=\"src/script.ts\" type=\"module\"></script>\n</head>\n\n<body>\n  <h1>Display your Spotify Profile Data</h1>\n\n  <section id=\"profile\">\n    <h2>Logged in as <span id=\"displayName\"></span></h2>\n    <img id=\"avatar\" width=\"200\" src=\"#\" />\n    <ul>\n      <li>User ID: <span id=\"id\"></span></li>\n      <li>Email: <span id=\"email\"></span></li>\n      <li>Spotify URI: <a id=\"uri\" href=\"#\"></a></li>\n      <li>Link: <a id=\"url\" href=\"#\"></a></li>\n      <li>Profile Image: <span id=\"imgUrl\"></span></li>\n    </ul>\n  </section>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "get_user_profile/package.json",
    "content": "{\n  \"name\": \"vite-project\",\n  \"private\": true,\n  \"version\": \"0.0.0\",\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \"vite\",\n    \"build\": \"tsc && vite build\",\n    \"preview\": \"vite preview\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^4.9.3\",\n    \"vite\": \"^4.0.0\"\n  }\n}"
  },
  {
    "path": "get_user_profile/src/authCodeWithPkce.ts",
    "content": "export async function redirectToAuthCodeFlow(clientId: string) {\n    const verifier = generateCodeVerifier(128);\n    const challenge = await generateCodeChallenge(verifier);\n\n    localStorage.setItem(\"verifier\", verifier);\n\n    const params = new URLSearchParams();\n    params.append(\"client_id\", clientId);\n    params.append(\"response_type\", \"code\");\n    params.append(\"redirect_uri\", \"http://localhost:5173/callback\");\n    params.append(\"scope\", \"user-read-private user-read-email\");\n    params.append(\"code_challenge_method\", \"S256\");\n    params.append(\"code_challenge\", challenge);\n\n    document.location = `https://accounts.spotify.com/authorize?${params.toString()}`;\n}\n\nexport async function getAccessToken(clientId: string, code: string) {\n    const verifier = localStorage.getItem(\"verifier\");\n\n    const params = new URLSearchParams();\n    params.append(\"client_id\", clientId);\n    params.append(\"grant_type\", \"authorization_code\");\n    params.append(\"code\", code);\n    params.append(\"redirect_uri\", \"http://localhost:5173/callback\");\n    params.append(\"code_verifier\", verifier!);\n\n    const result = await fetch(\"https://accounts.spotify.com/api/token\", {\n        method: \"POST\",\n        headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n        body: params\n    });\n\n    const { access_token } = await result.json();\n    return access_token;\n}\n\nfunction generateCodeVerifier(length: number) {\n    let text = '';\n    let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n    for (let i = 0; i < length; i++) {\n        text += possible.charAt(Math.floor(Math.random() * possible.length));\n    }\n    return text;\n}\n\nasync function generateCodeChallenge(codeVerifier: string) {\n    const data = new TextEncoder().encode(codeVerifier);\n    const digest = await window.crypto.subtle.digest('SHA-256', data);\n    return btoa(String.fromCharCode.apply(null, [...new Uint8Array(digest)]))\n        .replace(/\\+/g, '-')\n        .replace(/\\//g, '_')\n        .replace(/=+$/, '');\n}\n"
  },
  {
    "path": "get_user_profile/src/script.ts",
    "content": "// Because this is a literal single page application\n// we detect a callback from Spotify by checking for the hash fragment\nimport { redirectToAuthCodeFlow, getAccessToken } from \"./authCodeWithPkce\";\n\nconst clientId = \"your_client_id\";\nconst params = new URLSearchParams(window.location.search);\nconst code = params.get(\"code\");\n\nif (!code) {\n    redirectToAuthCodeFlow(clientId);\n} else {\n    const accessToken = await getAccessToken(clientId, code);\n    const profile = await fetchProfile(accessToken);\n    populateUI(profile);\n}\n\nasync function fetchProfile(code: string): Promise<UserProfile> {\n    const result = await fetch(\"https://api.spotify.com/v1/me\", {\n        method: \"GET\", headers: { Authorization: `Bearer ${code}` }\n    });\n\n    return await result.json();\n}\n\nfunction populateUI(profile: UserProfile) {\n    document.getElementById(\"displayName\")!.innerText = profile.display_name;\n    document.getElementById(\"avatar\")!.setAttribute(\"src\", profile.images[0].url)\n    document.getElementById(\"id\")!.innerText = profile.id;\n    document.getElementById(\"email\")!.innerText = profile.email;\n    document.getElementById(\"uri\")!.innerText = profile.uri;\n    document.getElementById(\"uri\")!.setAttribute(\"href\", profile.external_urls.spotify);\n    document.getElementById(\"url\")!.innerText = profile.href;\n    document.getElementById(\"url\")!.setAttribute(\"href\", profile.href);\n    document.getElementById(\"imgUrl\")!.innerText = profile.images[0].url;\n}\n"
  },
  {
    "path": "get_user_profile/src/types.d.ts",
    "content": "interface UserProfile {\n    country: string;\n    display_name: string;\n    email: string;\n    explicit_content: {\n        filter_enabled: boolean,\n        filter_locked: boolean\n    },\n    external_urls: { spotify: string; };\n    followers: { href: string; total: number; };\n    href: string;\n    id: string;\n    images: Image[];\n    product: string;\n    type: string;\n    uri: string;\n}\n\ninterface Image {\n    url: string;\n    height: number;\n    width: number;\n}\n"
  },
  {
    "path": "get_user_profile/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"ESNext\",\n    \"useDefineForClassFields\": true,\n    \"module\": \"ESNext\",\n    \"lib\": [\"ESNext\", \"DOM\"],\n    \"moduleResolution\": \"Node\",\n    \"strict\": true,\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"esModuleInterop\": true,\n    \"noEmit\": true,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": true,\n    \"noImplicitReturns\": true,\n    \"skipLibCheck\": true\n  },\n  \"include\": [\"src\"]\n}\n"
  }
]