From c31fb1181e0afd078160e39e706c069d04de0c6b Mon Sep 17 00:00:00 2001 From: fengyuexingzi Date: Wed, 13 Jun 2018 13:14:16 +0800 Subject: [PATCH] token --- auth/linkedin/callback.php | 9 +++++---- auth/linkedin/index.php | 8 +++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/auth/linkedin/callback.php b/auth/linkedin/callback.php index e30d0dd..096da4c 100644 --- a/auth/linkedin/callback.php +++ b/auth/linkedin/callback.php @@ -9,8 +9,7 @@ require_once "./function.php"; session_start(); - -$state = 'x1Dr3Nu0AaxM1TuLVuGwAJWM'; +$state = $_SESSION['state']; // step 1: get access token by code function getAccessToken($code) @@ -74,6 +73,8 @@ if ($_GET['state'] != $state) { die('hack'); } -//$access_token = getAccessToken($_GET['code']); +dump($_REQUEST); +dump($_SESSION); + +$access_token = getAccessToken($_GET['code']); -dump($_SESSION); \ No newline at end of file diff --git a/auth/linkedin/index.php b/auth/linkedin/index.php index 9fe06b1..3fd974c 100644 --- a/auth/linkedin/index.php +++ b/auth/linkedin/index.php @@ -6,15 +6,13 @@ * Time: 15:17 */ -session_start(); -$_SESSION['auth_name'] = '小小'; - require_once "./function.php"; // get_code_url = "https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=81cc4t9fuu9bpu&redirect_uri=https%3A%2F%2Ffengyuexingzi.top%2Fauth%2Flinkedin&state=Wf6tYXQ7y86iRulBOC%2FUXraHneM%3D&scope=r_fullprofile%20r_emailaddress%20w_share"; -// $state = base64_encode(openssl_random_pseudo_bytes(20)); -$state = 'x1Dr3Nu0AaxM1TuLVuGwAJWM'; +$state = base64_encode(openssl_random_pseudo_bytes(20)); +session_start(); +$_SESSION['$state'] = $state; function getCodeUrl() {