Hi Nik.

The example code looks like this:

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



You should change that to look like this if you want to pass your OAuth2 
credentials in from a db instead of from the file.

Enter code here...$oAuth2Credential = (new OAuth2TokenBuilder())

        ->withClientId(your oauth2 client id here)
        ->withClientSecret(your oauth2 client secret here)
        ->withRefreshToken(your stored refresh token here)
        ->build();





On Monday, 4 June 2018 19:02:00 UTC+1, nnik wrote:
>
> Hi folks, 
>
> I want to ask the adwords api to request my campaigns.
>
> I am using this simple example:
>
> $redirectUri = 'http://xxxxxxx/dashboard/accounts/oauth2callback';
> $code = $_GET['code'];
>
> $oauth2 = new OAuth2([
>     'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
>     'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
>     'redirectUri' => $redirectUri,
>     'clientId' => $this->client_id,
>     'clientSecret' => $this->client_secret,
>     'scope' => '****'
> ]);
>
> $oauth2->setCode($code);
> $authToken = $oauth2->fetchAuthToken();
>
> // Store the refresh token for your user in your local storage if you
> // requested offline access.
> $refreshToken = $authToken['refresh_token'];
> Now I have the access_token and the refresh_token.
>
> How can I use this to request google adwords now? When I am checking this 
> example: 
> https://developers.google.com/adwords/api/docs/samples/php/basic-operations
>
> The authentication data is coming from some local file, but I have the 
> data in my array above and the tokens are coming from the DB. 
>
> Thanks
> Nik
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1aa965af-0dde-4913-82d9-7ae60e36fc87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... nnik
    • ... 'Bharani Cherukuri (AdWords API Team)' via AdWords API and Google Ads API Forum
    • ... Peter Bowen

Reply via email to