Skip to content

Commit

Permalink
Fix auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvarado91 committed Sep 4, 2024
1 parent 34db271 commit 2732ce2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/server/crosscutting/soundCloudApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios, { AxiosInstance, AxiosResponse } from "axios";
import { Buffer } from "buffer";

const SOUNDCLOUD_CLIENT_ID =
process.env.SOUNDCLOUD_CLIENT_ID || "no_sound_client_id_read";
Expand Down Expand Up @@ -28,9 +29,21 @@ export class SoundCloudApiClient {
}

async getToken() {
const res = await this.client
const credentials = `${SOUNDCLOUD_CLIENT_ID}:${SOUNDCLOUD_CLIENT_SECRET}`;
const encodedCredentials = Buffer.from(credentials).toString("base64");

const res = await axios
.post<{ access_token: string }>(
`/oauth2/token?client_id=${SOUNDCLOUD_CLIENT_ID}&client_secret=${SOUNDCLOUD_CLIENT_SECRET}&grant_type=client_credentials`
"https://secure.soundcloud.com/oauth/token",
new URLSearchParams({
grant_type: "client_credentials",
}),
{
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Basic ${encodedCredentials}`,
},
}
)
.then(this._data);

Expand Down

1 comment on commit 2732ce2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for soulector ready!

✅ Preview
https://soulector-mp05uxyq6-juan-alvarados-projects-746f4d3e.vercel.app

Built with commit 2732ce2.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.