Skip to content

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

Open
@ShailzaDev

Description

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');
            }        
    } 
   }

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions