What security considerations should be taken into account when handling sensitive data like access tokens in PHP scripts for API integration?

When handling sensitive data like access tokens in PHP scripts for API integration, it is crucial to store these tokens securely to prevent unauthorized access. One common approach is to store the access tokens in environment variables or a configuration file outside of the web root directory. This helps to prevent the tokens from being exposed in case of a security breach.

// Storing access token securely in an environment variable
$accessToken = getenv('API_ACCESS_TOKEN');

// Using the access token in API requests
// Example:
// $client->setAccessToken($accessToken);