How to pass OAuth data from database to API in V201708

97 views
Skip to first unread message

silvester correya

unread,
Sep 18, 2017, 8:08:14 AM9/18/17
to AdWords API Forum

Hi support,


while  trying to migrate Adwords API to v201708 , Iam stuck of how to pass outh data  stored in my database to API

 $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

$session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->build();

 

Could someone help me to solve this issue.

 

Thanks,

Joseph

Bharani Cherukuri (AdWords API Team)

unread,
Sep 18, 2017, 1:13:13 PM9/18/17
to AdWords API Forum
Hello Joseph, 

The PHP client library looks for the configuration file in the home directory of the user running the script, to fill out the required properties here in the adsapi_php.ini file. If the home directory is not set correctly or if the library is not able to find the home directory, you can specify the configuration file path by passing as an argument to the fromFile() method. You can refer to our PHP client library for additional guidance. If you are still facing issues, please send me the SOAP request and response logs for the API call. Please click on Reply privately to author when responding.

Thanks,
Bharani, AdWords API Team

Bharani Cherukuri (AdWords API Team)

unread,
Sep 19, 2017, 2:33:23 PM9/19/17
to AdWords API Forum
Hello Joseph,

You will be able to use OAuth2TokenBuilder and AdWordsSessionBuilder to pass the values programmatically.

   $oAuth2Credential = (new OAuth2TokenBuilder())
      
->withClientId("OAUTH_2_CLIENT_ID")
      
->withClientSecret("OAUTH_2_CLIENT_SECRET")
      
->withRefreshToken("REFRESH_TOKEN")
      
->build();

    
// Construct an API session configured from the OAuth2 credentials above.
    $session 
= (new AdWordsSessionBuilder())
        
->withDeveloperToken("DEVELOPER_TOKEN")
        
->withOAuth2Credential($oAuth2Credential)
        
->withClientCustomerId("CLIENT_CUSTOMER_ID")
        
->build();

The OAuth2TokenBuilder will fetch the access tokens when required. The AdWordsSessionBuilder uses the oAuth2Credential object to build the AdsSession. If you have any further questions, I'd suggest that you post your concern on the library's issue tracker so the library owners can help you out.

Thanks,
Bharani, AdWords API Team

On Monday, September 18, 2017 at 8:08:14 AM UTC-4, silvester correya wrote:
Reply all
Reply to author
Forward
0 new messages