• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Zaptyp / spotify-web-api-node / 14459668359

15 Apr 2025 02:05AM UTC coverage: 95.264%. Remained the same
14459668359

Pull #16

travis-ci

web-flow
Bump actions/setup-node from 4.3.0 to 4.4.0

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 4.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #16: Bump actions/setup-node from 4.3.0 to 4.4.0

170 of 185 branches covered (91.89%)

Branch coverage included in aggregate %.

353 of 364 relevant lines covered (96.98%)

70.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/server-methods.js
1
'use strict';
2

3
var AuthenticationRequest = require('./authentication-request');
2✔
4
var HttpManager = require('./http-manager');
2✔
5

6
module.exports = {
2✔
7
  /**
8
   * Retrieve a URL where the user can give the application permissions.
9
   * @param {string[]} scopes The scopes corresponding to the permissions the application needs.
10
   * @param {string} state A parameter that you can use to maintain a value between the request and the callback to redirect_uri.It is useful to prevent CSRF exploits.
11
   * @param {boolean} showDialog A parameter that you can use to force the user to approve the app on each login rather than being automatically redirected.
12
   * @param {string} responseType An optional parameter that you can use to specify the code response based on the authentication type - can be set to 'code' or 'token'. Default 'code' to ensure backwards compatability.
13
   * @returns {string} The URL where the user can give application permissions.
14
   */
15
  createAuthorizeURL: function (
16
    scopes,
17
    state,
18
    showDialog,
19
    responseType = 'code'
2✔
20
  ) {
21
    return AuthenticationRequest.builder()
6✔
22
      .withPath('/authorize')
23
      .withQueryParameters({
24
        client_id: this.getClientId(),
25
        response_type: responseType,
26
        redirect_uri: this.getRedirectURI(),
27
        scope: scopes.join('%20'),
28
        state: state,
29
        show_dialog: showDialog && !!showDialog
5✔
30
      })
31
      .build()
32
      .getURL();
33
  },
34

35
  /**
36
   * Request an access token using the Client Credentials flow.
37
   * Requires that client ID and client secret has been set previous to the call.
38
   * @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
39
   * @returns {Promise|undefined} A promise that if successful, resolves into an object containing the access token,
40
   *          token type and time to expiration. If rejected, it contains an error object. Not returned if a callback is given.
41
   */
42
  clientCredentialsGrant: function (callback) {
43
    return AuthenticationRequest.builder()
2✔
44
      .withPath('/api/token')
45
      .withBodyParameters({
46
        grant_type: 'client_credentials'
47
      })
48
      .withHeaders({
49
        Authorization:
50
          'Basic ' +
51
          new Buffer(
52
            this.getClientId() + ':' + this.getClientSecret()
53
          ).toString('base64'),
54
        'Content-Type': 'application/x-www-form-urlencoded'
55
      })
56
      .build()
57
      .execute(HttpManager.post, callback);
58
  },
59

60
  /**
61
   * Request an access token using the Authorization Code flow.
62
   * Requires that client ID, client secret, and redirect URI has been set previous to the call.
63
   * @param {string} code The authorization code returned in the callback in the Authorization Code flow.
64
   * @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
65
   * @returns {Promise|undefined} A promise that if successful, resolves into an object containing the access token,
66
   *          refresh token, token type and time to expiration. If rejected, it contains an error object.
67
   *          Not returned if a callback is given.
68
   */
69
  authorizationCodeGrant: function (code, callback) {
70
    return AuthenticationRequest.builder()
2✔
71
      .withPath('/api/token')
72
      .withBodyParameters({
73
        grant_type: 'authorization_code',
74
        redirect_uri: this.getRedirectURI(),
75
        code: code,
76
        client_id: this.getClientId(),
77
        client_secret: this.getClientSecret()
78
      })
79
      .withHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' })
80
      .build()
81
      .execute(HttpManager.post, callback);
82
  },
83

84
  /**
85
   * Refresh the access token given that it hasn't expired.
86
   * Requires that client ID, client secret and refresh token has been set previous to the call.
87
   * @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
88
   * @returns {Promise|undefined} A promise that if successful, resolves to an object containing the
89
   *          access token, time to expiration and token type. If rejected, it contains an error object.
90
   *          Not returned if a callback is given.
91
   */
92
  refreshAccessToken: function (callback) {
93
    return AuthenticationRequest.builder()
4✔
94
      .withPath('/api/token')
95
      .withBodyParameters({
96
        grant_type: 'refresh_token',
97
        refresh_token: this.getRefreshToken()
98
      })
99
      .withHeaders({
100
        Authorization:
101
          'Basic ' +
102
          new Buffer(
103
            this.getClientId() + ':' + this.getClientSecret()
104
          ).toString('base64'),
105
        'Content-Type': 'application/x-www-form-urlencoded'
106
      })
107
      .build()
108
      .execute(HttpManager.post, callback);
109
  }
110
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc