src/DataService/DataService.php
private function configureOAuth2LoginHelper($oauth2Conifg, $settings)
    {
          $refreshToken = CoreConstants::getRefreshTokenFromArray($settings);
          if(isset($refreshToken)){
               //Login helper for refresh token API call
               $this->OAuth2LoginHelper = new OAuth2LoginHelper(null,
                                                                null,
                                                                null,
                                                                null,
                                                                null,
                                                                $this->getServiceContext());
          }else{
                $redirectURL = CoreConstants::getRedirectURL($settings);
                $scope = array_key_exists('scope', $settings) ? $settings['scope'] : null;
                $state = array_key_exists('state', $settings) ? $settings['state'] : null;
                $this->OAuth2LoginHelper = new OAuth2LoginHelper($oauth2Conifg->getClientID(),
                                                                 $oauth2Conifg->getClientSecret(),
                                                                 $redirectURL,
                                                                 $scope,
                                                                 $state);
          }
    }
private function configureOAuth2LoginHelper($oauth2Conifg, $settings)
    {
          $refreshToken = CoreConstants::getRefreshTokenFromArray($settings);
          if(isset($refreshToken)){
               //Login helper for refresh token API call
               $this->OAuth2LoginHelper = new OAuth2LoginHelper(null,
                                                                null,
                                                                null,
                                                                null,
                                                                null,
                                                                $this->getServiceContext());
          }else{
                $redirectURL = CoreConstants::getRedirectURL($settings);
                $scope = array_key_exists('scope', $settings) ? $settings['scope'] : null;
                $state = array_key_exists('state', $settings) ? $settings['state'] : null;
                $this->OAuth2LoginHelper = new OAuth2LoginHelper($oauth2Conifg->getClientID(),
                                                                 $oauth2Conifg->getClientSecret(),
                                                                 $redirectURL,
                                                                 $scope,
                                                                 $state);
          }
    }
After the ServiceContext is complete, also set the LoginHelper based on the ServiceContext.
@param OAuth2AccessToken $oauth2Conifg      OAuth 2 Token related information
@param Array $settings                      The array that include the redirectURL, scope, state information