setAuthConfig($serviceAccountPath); $client->addScope('https://www.googleapis.com/auth/firebase.messaging'); $client->useApplicationDefaultCredentials(); $token = $client->fetchAccessTokenWithAssertion(); return $token['access_token']; } $serviceAccountPath = 'service-account-file.