UNPKG

@kkbox/kkbox-js-sdk

Version:

KKBOX Open API developer SDK for JavaScript. Use it to easily access KKBOX open API to get various metadata about KKBOX's tracks, albums, artists, playlists and stations.

53 lines (43 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Implements the client credentials flow. Used for accessing APIs that don't need any KKBOX * user's personal data. * @see https://docs-en.kkbox.codes/docs/getting-started */ var ClientCredentialsFlow = /*#__PURE__*/ function () { /** * @ignore */ function ClientCredentialsFlow(token) { _classCallCheck(this, ClientCredentialsFlow); /** * @ignore */ this.token = token; } /** * Fetch access token. * * @return {Promise} * @example auth.clientCredentialsFlow.fetchAccessToken(); */ _createClass(ClientCredentialsFlow, [{ key: "fetchAccessToken", value: function fetchAccessToken() { return this.token.fetchAccessToken({ grant_type: 'client_credentials' }); } }]); return ClientCredentialsFlow; }(); exports["default"] = ClientCredentialsFlow;