public static function initializeOAuthSettings($xmlObj, $ippConfig, $OAuthOption)
   {

         // if it is OAuth1 Settings.
         if (isset($xmlObj) &&
                 isset($xmlObj->intuit->ipp->security) &&
                 $OAuthOption == CoreConstants::OAUTH1  &&
                 isset($xmlObj->intuit->ipp->security->oauth1)) {
             try {
                 $currentAccessTokenKey = $xmlObj->intuit->ipp->security->oauth1->attributes()['accessTokenKey'];
                 $currentAccessTokenSecret = $xmlObj->intuit->ipp->security->oauth1->attributes()['accessTokenSecret'];
                 $currentConsumerKey = $xmlObj->intuit->ipp->security->oauth1->attributes()['consumerKey'];
                 $currentConsumerSecret =    $xmlObj->intuit->ipp->security->oauth1->attributes()['consumerSecret'];
                 $ippConfig->RealmID =  $xmlObj->intuit->ipp->security->oauth1->attributes()['QBORealmID'];
                 $ippConfig->OAuthMode = CoreConstants::OAUTH1;
             } catch (\Exception $e) {
                 throw new \Exception("Can't Read OAuth1 values from config file.");
             }
             $ippConfig->Security = new OAuthRequestValidator($currentAccessTokenKey, $currentAccessTokenSecret, $currentConsumerKey, $currentConsumerSecret);
         }
         // OAUth 2 settings if available
         elseif (isset($xmlObj) &&
                 isset($xmlObj->intuit->ipp->security) &&
                 $OAuthOption == CoreConstants::OAUTH2  &&
                 isset($xmlObj->intuit->ipp->security->oauth2)) {
             //Implement OAuth 2 parts here
            // Set SSL check status to be true
            $ippConfig->SSLCheckStatus = true;
            $currentOAuth2AccessTokenKey = $xmlObj->intuit->ipp->security->oauth2->attributes()['accessTokenKey'];
            $currentOAuth2RefreshTokenKey = $xmlObj->intuit->ipp->security->oauth2->attributes()['refreshTokenKey'];
            $clientID = $xmlObj->intuit->ipp->security->oauth2->attributes()['ClientID'];
            $clientSecret =    $xmlObj->intuit->ipp->security->oauth2->attributes()['ClientSecret'];
            $ippConfig->RealmID =  $xmlObj->intuit->ipp->security->oauth2->attributes()['QBORealmID'];
            $OAuth2AccessToken = new OAuth2AccessToken($clientID, $clientSecret, $currentOAuth2AccessTokenKey, $currentOAuth2RefreshTokenKey);

            $ippConfig->Security = $OAuth2AccessToken;
            $ippConfig->OAuthMode = CoreConstants::OAUTH2;
         } else {
             throw new \Exception("Can't load " .$OAuthOption .  " config from config file or the OAuth option is not supported.");
         }
   }
public static function initializeOAuthSettings($xmlObj, $ippConfig, $OAuthOption)
   {

         // if it is OAuth1 Settings.
         if (isset($xmlObj) &&
                 isset($xmlObj->intuit->ipp->security) &&
                 $OAuthOption == CoreConstants::OAUTH1  &&
                 isset($xmlObj->intuit->ipp->security->oauth1)) {
             try {
                 $currentAccessTokenKey = $xmlObj->intuit->ipp->security->oauth1->attributes()['accessTokenKey'];
                 $currentAccessTokenSecret = $xmlObj->intuit->ipp->security->oauth1->attributes()['accessTokenSecret'];
                 $currentConsumerKey = $xmlObj->intuit->ipp->security->oauth1->attributes()['consumerKey'];
                 $currentConsumerSecret =    $xmlObj->intuit->ipp->security->oauth1->attributes()['consumerSecret'];
                 $ippConfig->RealmID =  $xmlObj->intuit->ipp->security->oauth1->attributes()['QBORealmID'];
                 $ippConfig->OAuthMode = CoreConstants::OAUTH1;
             } catch (\Exception $e) {
                 throw new \Exception("Can't Read OAuth1 values from config file.");
             }
             $ippConfig->Security = new OAuthRequestValidator($currentAccessTokenKey, $currentAccessTokenSecret, $currentConsumerKey, $currentConsumerSecret);
         }
         // OAUth 2 settings if available
         elseif (isset($xmlObj) &&
                 isset($xmlObj->intuit->ipp->security) &&
                 $OAuthOption == CoreConstants::OAUTH2  &&
                 isset($xmlObj->intuit->ipp->security->oauth2)) {
             //Implement OAuth 2 parts here
            // Set SSL check status to be true
            $ippConfig->SSLCheckStatus = true;
            $currentOAuth2AccessTokenKey = $xmlObj->intuit->ipp->security->oauth2->attributes()['accessTokenKey'];
            $currentOAuth2RefreshTokenKey = $xmlObj->intuit->ipp->security->oauth2->attributes()['refreshTokenKey'];
            $clientID = $xmlObj->intuit->ipp->security->oauth2->attributes()['ClientID'];
            $clientSecret =    $xmlObj->intuit->ipp->security->oauth2->attributes()['ClientSecret'];
            $ippConfig->RealmID =  $xmlObj->intuit->ipp->security->oauth2->attributes()['QBORealmID'];
            $OAuth2AccessToken = new OAuth2AccessToken($clientID, $clientSecret, $currentOAuth2AccessTokenKey, $currentOAuth2RefreshTokenKey);

            $ippConfig->Security = $OAuth2AccessToken;
            $ippConfig->OAuthMode = CoreConstants::OAUTH2;
         } else {
             throw new \Exception("Can't load " .$OAuthOption .  " config from config file or the OAuth option is not supported.");
         }
   }
public static function initializeOAuthSettings ( $ xmlObj , $ ippConfig , $ OAuthOption ) { // if it is OAuth1 Settings. if ( isset ( $ xmlObj ) && isset ( $ xmlObj -> intuit -> ipp -> security ) && $ OAuthOption == CoreConstants :: OAUTH1 && isset ( $ xmlObj -> intuit -> ipp -> security -> oauth1 ) ) { try { $ currentAccessTokenKey = $ xmlObj -> intuit -> ipp -> security -> oauth1 -> attributes ( ) [ 'accessTokenKey' ] ; $ currentAccessTokenSecret = $ xmlObj -> intuit -> ipp -> security -> oauth1 -> attributes ( ) [ 'accessTokenSecret' ] ; $ currentConsumerKey = $ xmlObj -> intuit -> ipp -> security -> oauth1 -> attributes ( ) [ 'consumerKey' ] ; $ currentConsumerSecret = $ xmlObj -> intuit -> ipp -> security -> oauth1 -> attributes ( ) [ 'consumerSecret' ] ; $ ippConfig -> RealmID = $ xmlObj -> intuit -> ipp -> security -> oauth1 -> attributes ( ) [ 'QBORealmID' ] ; $ ippConfig -> OAuthMode = CoreConstants :: OAUTH1 ; } catch ( \ Exception $ e ) { throw new \ Exception ( "Can't Read OAuth1 values from config file." ) ; } $ ippConfig -> Security = new OAuthRequestValidator ( $ currentAccessTokenKey , $ currentAccessTokenSecret , $ currentConsumerKey , $ currentConsumerSecret ) ; } // OAUth 2 settings if available elseif ( isset ( $ xmlObj ) && isset ( $ xmlObj -> intuit -> ipp -> security ) && $ OAuthOption == CoreConstants :: OAUTH2 && isset ( $ xmlObj -> intuit -> ipp -> security -> oauth2 ) ) { //Implement OAuth 2 parts here // Set SSL check status to be true $ ippConfig -> SSLCheckStatus = true ; $ currentOAuth2AccessTokenKey = $ xmlObj -> intuit -> ipp -> security -> oauth2 -> attributes ( ) [ 'accessTokenKey' ] ; $ currentOAuth2RefreshTokenKey = $ xmlObj -> intuit -> ipp -> security -> oauth2 -> attributes ( ) [ 'refreshTokenKey' ] ; $ clientID = $ xmlObj -> intuit -> ipp -> security -> oauth2 -> attributes ( ) [ 'ClientID' ] ; $ clientSecret = $ xmlObj -> intuit -> ipp -> security -> oauth2 -> attributes ( ) [ 'ClientSecret' ] ; $ ippConfig -> RealmID = $ xmlObj -> intuit -> ipp -> security -> oauth2 -> attributes ( ) [ 'QBORealmID' ] ; $ OAuth2AccessToken = new OAuth2AccessToken ( $ clientID , $ clientSecret , $ currentOAuth2AccessTokenKey , $ currentOAuth2RefreshTokenKey ) ; $ ippConfig -> Security = $ OAuth2AccessToken ; $ ippConfig -> OAuthMode = CoreConstants :: OAUTH2 ; } else { throw new \ Exception ( "Can't load " . $ OAuthOption . " config from config file or the OAuth option is not supported." ) ; } }
Initialize OAuth Settings from Simple XML Reading from SDK.config or specific file
rightnow the default OAuth module is OAuth 1.
@Hao
Initialize OAuth Settings from Simple XML Reading from SDK . config or specific file rightnow the default OAuth module is OAuth 1 .