oauth=new OneDriveOauth(); $this->oauth->setClientId($clientId); $this->oauth->setClientSecret($clientSecret); $this->oauth->setTenantId($tenantId); } public function dispatch(){ if($code=$this->getCode()){ try{ $result=$this->oauth->fetchAccessTokenWithAuthCode($code); $refreshToken=$result['refresh_token']; }catch (Exception $e){ $refreshToken=$e->getMessage(); } catch (GuzzleException $e) { $refreshToken=$e->getMessage(); } $this->showRefreshToken($refreshToken); }else{ $this->redirectTo($this->oauth->createAuthUrl()); } } protected function redirectTo($url){ $redirect=' Redirecting.... Redirecting to %1$s... '; printf($redirect,$url); } protected function showRefreshToken($refreshToken){ echo ''; } protected function getCode(){ return $_REQUEST['code']??null; } }