Fall back to \$_SERVER for LinkedIn env vars to support PHP-FPM
Apache SetEnv doesn't reach PHP-FPM processes via getenv(), but the values are still available in \$_SERVER. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f6e768c246
commit
e8e4476a58
2 changed files with 3 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ $stmt = $db->prepare('SELECT * FROM projects WHERE id = ? AND is_active = 1');
|
||||||
$stmt->execute([$pid]);
|
$stmt->execute([$pid]);
|
||||||
if (!$stmt->fetch()) { http_response_code(404); echo json_encode(['error' => 'Project not found']); exit; }
|
if (!$stmt->fetch()) { http_response_code(404); echo json_encode(['error' => 'Project not found']); exit; }
|
||||||
|
|
||||||
$client_id = getenv('LINKEDIN_CLIENT_ID');
|
$client_id = getenv('LINKEDIN_CLIENT_ID') ?: ($_SERVER['LINKEDIN_CLIENT_ID'] ?? null);
|
||||||
if (!$client_id) { echo json_encode(['error' => 'LINKEDIN_CLIENT_ID not set in server environment']); exit; }
|
if (!$client_id) { echo json_encode(['error' => 'LINKEDIN_CLIENT_ID not set in server environment']); exit; }
|
||||||
|
|
||||||
$state = bin2hex(random_bytes(16));
|
$state = bin2hex(random_bytes(16));
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ if (isset($_GET['error'])) {
|
||||||
$code = $_GET['code'] ?? '';
|
$code = $_GET['code'] ?? '';
|
||||||
if (!$code) { echo 'Missing code. <a href="/">Go back</a>'; exit; }
|
if (!$code) { echo 'Missing code. <a href="/">Go back</a>'; exit; }
|
||||||
|
|
||||||
$client_id = getenv('LINKEDIN_CLIENT_ID');
|
$client_id = getenv('LINKEDIN_CLIENT_ID') ?: ($_SERVER['LINKEDIN_CLIENT_ID'] ?? null);
|
||||||
$client_secret = getenv('LINKEDIN_CLIENT_SECRET');
|
$client_secret = getenv('LINKEDIN_CLIENT_SECRET') ?: ($_SERVER['LINKEDIN_CLIENT_SECRET'] ?? null);
|
||||||
$redirect_uri = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/linkedin/callback';
|
$redirect_uri = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/linkedin/callback';
|
||||||
|
|
||||||
// Exchange code for tokens
|
// Exchange code for tokens
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue