Announcements

Help Wizard

Step 1

NEXT STEP

Client Secret and client ID...

Client Secret and client ID...

Plan

Free/Premium

Country

 

Device

(iPhone 8, Samsung Galaxy 9, Macbook Pro late 2016)

Operating System

(iOS 10, Android Oreo, Windows 10,etc.)

 

My Question or Issue

I'm wondering the best way to use the values given to us from Spotify. Can we use our secrect and ID in a php or javascipt file or is .env the best way to go? As shown here they are using php files: 

require 'vendor/autoload.php';

$session = new SpotifyWebAPI\Session(
'CLIENT_ID',
'CLIENT_SECRET',
'REDIRECT_URI'
);

$state = $session->generateState();
$options = [
'scope' => [
'playlist-read-private',
'user-read-private',
],
'state' => $state,
];

header('Location: ' . $session->getAuthorizeUrl($options));
die();

Reply
1 Reply

Hi @MarlaMM 

Thank you for posting in the Spotify Community, and Welcome!

 

Best practice is to keep keys out of your code, so I recommend you to make use of .env files.

 

Cheers!

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random