<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic No token provided angular spotify api in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614439#M10119</link>
    <description>&lt;P&gt;**Code is in Angular typescript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an access token using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    getToken() {
        const headers = new HttpHeaders({
            'Content-Type': 'application/x-www-form-urlencoded'
          });
          return this.http.post('https://accounts.spotify.com/api/token', 'grant_type=client_credentials&amp;amp;client_id=c9477994743c439ba8cbe8591b96275b&amp;amp;client_secret=d118aa20a1904049ac3cc905077944ff', { headers: headers });
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;DIV&gt;I then tried to call an endpoint using:&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    getArtist() {
        const headers = new HttpHeaders({
            'Authorization': 'BQA1O6zV2ZmW0RVIEZFFtQPgGL5uLV_iji0nZkSwwwmmdAmKyRKjKNuQn_UjIgx7gUBzhcB30VhuZZ5XE29PwEKNjnHLcJj-chSk6BA7u-faFsnKH7c'
          });
        return this.http.post('https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb', { headers: headers });
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, it keeps giving me the 401 error that I did not provide a token. I feel like my code is correct?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 25 Jul 2023 20:26:59 GMT</pubDate>
    <dc:creator>user-removed</dc:creator>
    <dc:date>2023-07-25T20:26:59Z</dc:date>
    <item>
      <title>No token provided angular spotify api</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614439#M10119</link>
      <description>&lt;P&gt;**Code is in Angular typescript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got an access token using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    getToken() {
        const headers = new HttpHeaders({
            'Content-Type': 'application/x-www-form-urlencoded'
          });
          return this.http.post('https://accounts.spotify.com/api/token', 'grant_type=client_credentials&amp;amp;client_id=c9477994743c439ba8cbe8591b96275b&amp;amp;client_secret=d118aa20a1904049ac3cc905077944ff', { headers: headers });
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;DIV&gt;I then tried to call an endpoint using:&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    getArtist() {
        const headers = new HttpHeaders({
            'Authorization': 'BQA1O6zV2ZmW0RVIEZFFtQPgGL5uLV_iji0nZkSwwwmmdAmKyRKjKNuQn_UjIgx7gUBzhcB30VhuZZ5XE29PwEKNjnHLcJj-chSk6BA7u-faFsnKH7c'
          });
        return this.http.post('https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb', { headers: headers });
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, it keeps giving me the 401 error that I did not provide a token. I feel like my code is correct?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Jul 2023 20:26:59 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614439#M10119</guid>
      <dc:creator>user-removed</dc:creator>
      <dc:date>2023-07-25T20:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: No token provided angular spotify api</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614532#M10122</link>
      <description>&lt;P&gt;As you&amp;nbsp;&lt;A href="https://developer.spotify.com/documentation/web-api/concepts/access-token" target="_blank" rel="noopener"&gt;can see here&lt;/A&gt;, you'll need to add the word &lt;EM&gt;Bearer&lt;/EM&gt; in front of the access token.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 08:30:50 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614532#M10122</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-07-26T08:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: No token provided angular spotify api</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614735#M10124</link>
      <description>&lt;P&gt;Unfortunately, I tried that and still got the same error. What I posted was my last attempt before moving on.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 11:38:13 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614735#M10124</guid>
      <dc:creator>user-removed</dc:creator>
      <dc:date>2023-07-26T11:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: No token provided angular spotify api</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614767#M10125</link>
      <description>&lt;P&gt;I see you get your access token in a very different way as &lt;A href="https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow" target="_blank" rel="noopener"&gt;shown at this page&lt;/A&gt;. Maybe there's the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 12:47:44 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5614767#M10125</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-07-26T12:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: No token provided angular spotify api</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5624377#M10350</link>
      <description>&lt;P&gt;I think you are missing the body while sending post request. Hope the Below code helps.&lt;BR /&gt;Also, you are missing to add Bearer in the Authorization header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;getToken(code: string, codeVerifier: string) {
    let httpHeaders: HttpHeaders = new HttpHeaders();
    httpHeaders = httpHeaders.set('Content-Type', 'application/x-www-form-urlencoded');

    let body = new URLSearchParams({
      grant_type: 'authorization_code',
      code: code,
      redirect_uri: this.REDIRECT_URL,
      client_id: this.CLIENT_ID,
      code_verifier: codeVerifier
    });

    this.http
      .post("https://accounts.spotify.com/api/token", body, { headers: httpHeaders })
      .pipe(
        catchError((error: HttpErrorResponse) =&amp;gt; {
          console.error("Error fetching token", error);
          return of(null);
        })
      )
      .subscribe((response: any) =&amp;gt; {
        if (response !== null) {
          this.tokenService.setAccessToken(response.access_token);
          this.tokenService.setRefreshToken(response.setRefreshToken);
          this.router.navigate(['sp-phile']);
        }
      });
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 17:07:03 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/No-token-provided-angular-spotify-api/m-p/5624377#M10350</guid>
      <dc:creator>navenduraisamy</dc:creator>
      <dc:date>2023-08-17T17:07:03Z</dc:date>
    </item>
  </channel>
</rss>

