From b44f15f141581d0f5270d77c3e92a77c0815a0c0 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 16 Jan 2021 11:28:19 +0800 Subject: [PATCH] fix bug: access token be 1 --- disk/Aliyundrive.php | 1 + disk/Onedrive.php | 1 + disk/OnedriveCN.php | 3 +-- disk/Sharelink.php | 1 + disk/Sharepoint.php | 3 +-- disk/SharepointCN.php | 3 +-- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/disk/Aliyundrive.php b/disk/Aliyundrive.php index 665df7e..aae403e 100644 --- a/disk/Aliyundrive.php +++ b/disk/Aliyundrive.php @@ -709,6 +709,7 @@ class Aliyundrive { $this->access_token = $ret['access_token']; savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300); if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ], $this->disktag); + return true; } return true; } diff --git a/disk/Onedrive.php b/disk/Onedrive.php index 807e42e..b5d9685 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -731,6 +731,7 @@ class Onedrive { $this->access_token = $ret['access_token']; savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300); if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ], $this->disktag); + return true; } return true; } diff --git a/disk/OnedriveCN.php b/disk/OnedriveCN.php index ecba9f7..8815e25 100644 --- a/disk/OnedriveCN.php +++ b/disk/OnedriveCN.php @@ -16,8 +16,7 @@ class OnedriveCN extends Onedrive { $this->oauth_url = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/'; $this->api_url = 'https://microsoftgraph.chinacloudapi.cn/v1.0'; $this->scope = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All offline_access'; - $this->access_token = getcache('access_token', $tag); - if (!$this->access_token) $this->access_token = $this->get_access_token(getConfig('refresh_token', $tag)); + $res = $this->get_access_token(getConfig('refresh_token', $tag)); $this->client_secret = urlencode($this->client_secret); $this->scope = urlencode($this->scope); diff --git a/disk/Sharelink.php b/disk/Sharelink.php index 94529d7..19f96bb 100644 --- a/disk/Sharelink.php +++ b/disk/Sharelink.php @@ -52,6 +52,7 @@ class Sharelink extends Onedrive { if (getConfig('shareapiurl', $this->disktag)!=$this->api_url) $tmp1['shareapiurl'] = $this->api_url; //if (getConfig('sharecookie', $this->disktag)!=$this->sharecookie) $tmp1['sharecookie'] = $this->sharecookie; if (!!$tmp1) setConfig($tmp1); + return true; } return true; } diff --git a/disk/Sharepoint.php b/disk/Sharepoint.php index f2d939d..9b5aa9a 100644 --- a/disk/Sharepoint.php +++ b/disk/Sharepoint.php @@ -16,8 +16,7 @@ class Sharepoint extends Onedrive { $this->oauth_url = 'https://login.microsoftonline.com/common/oauth2/v2.0/'; $this->api_url = 'https://graph.microsoft.com/v1.0'; $this->scope = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access'; - $this->access_token = getcache('access_token', $tag); - if (!$this->access_token) $this->access_token = $this->get_access_token(getConfig('refresh_token', $tag)); + $res = $this->get_access_token(getConfig('refresh_token', $tag)); $this->client_secret = urlencode($this->client_secret); $this->scope = urlencode($this->scope); diff --git a/disk/SharepointCN.php b/disk/SharepointCN.php index 7ab2a8b..3d426f3 100644 --- a/disk/SharepointCN.php +++ b/disk/SharepointCN.php @@ -16,8 +16,7 @@ class SharepointCN extends Onedrive { $this->oauth_url = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/'; $this->api_url = 'https://microsoftgraph.chinacloudapi.cn/v1.0'; $this->scope = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All offline_access'; - $this->access_token = getcache('access_token', $tag); - if (!$this->access_token) $this->access_token = $this->get_access_token(getConfig('refresh_token', $tag)); + $res = $this->get_access_token(getConfig('refresh_token', $tag)); $this->client_secret = urlencode($this->client_secret); $this->scope = urlencode($this->scope);