thephpleague / oauth2-client

Easy integration with OAuth 2.0 service providers.
http://oauth2-client.thephpleague.com
MIT License
3.66k stars 752 forks source link

Suddenly getting error Class "djchen\OAuth2\Client\Provider\Fitbit" not found #1028

Open ShailzaDev opened 7 months ago

ShailzaDev commented 7 months ago

djChen Library was working fine but suddenly getting error for it class not found use djchen\OAuth2\Client\Provider\Fitbit; protected function fetchDataForToken($token,$interval) { $tokenDetail = json_decode($token['token'], true); $accessToken = $tokenDetail['access_token']; $fitbitUserId = $tokenDetail['values']['user_id']; $refreshToken = $tokenDetail['refresh_token'];

    $expirationTime = $tokenDetail['expires'];

    $currentTimestamp = time();
    $provider = new Fitbit([
        'clientId'     => env('FITBIT_CLIENT_ID'),
        'clientSecret' => env('FITBIT_CLIENT_SECRET'),
        'redirectUri'  => env('FITBIT_REDIRECT_URI'),
    ]);

    $isExpired = $currentTimestamp >= $expirationTime;
    if ($isExpired) {
            $newAccessToken = $provider->getAccessToken('refresh_token', [
                'refresh_token' => $refreshToken
            ]);
            if($newAccessToken)
            {
                $accessToken = $newAccessToken->getToken();                  
                $refreshToken = $newAccessToken->getRefreshToken();
                // Update token details
                $tokenDetail['access_token'] = $accessToken;
                $tokenDetail['refresh_token'] = $refreshToken;
                $tokenDetail['expires'] = $newAccessToken->getExpires();

                $token['token'] = json_encode($tokenDetail);
                $this->info('token updated successfully');    
                $token->save();
                $this->info('Token updated successfully');
            }        
    } 
   }