Adwords + OAuth empty access code

28 views
Skip to first unread message

TheGMUniverse

unread,
Apr 3, 2018, 5:55:53 AM4/3/18
to AdWords API Forum
Hi, i am trying to log people in through Oauth to manage their Campaigns, but whenever i make a call for a session, i am not getting any access code returned:


This is how i use it:


    public function setOAuth($token){
        echo $token. "<br>";
        echo $this->client_id. "<br>";
        echo $this->client_secret. "<br>";
        echo $this->dev_token. "<br>";

        $oAuth2Credential = (new OAuth2TokenBuilder())
        ->withClientId($this->client_id)
        ->withClientSecret($this->client_secret)
        ->withRefreshToken($token)
        ->build();
        $soapSettings = (new SoapSettingsBuilder())->disableSslVerify()->build();
        echo "OAUTH<br>";
        echo "<pre>";
        print_r($oAuth2Credential);
        echo "</pre>";
        echo "SOAPSETTINGS<br>";
        echo "<pre>";
        print_r($soapSettings);
        echo "</pre>";
        $session = (new AdWordsSessionBuilder())
        ->withDeveloperToken($this->dev_token)
        //->withClientCustomerId('361-779-4901')
        ->withUserAgent('Hello')
        ->withSoapSettings($soapSettings)
        ->withOAuth2Credential($oAuth2Credential)
        ->build();

        return $session;
    }

Does anyone know how i can fix this?

Thanks!

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Apr 3, 2018, 2:28:01 PM4/3/18
to AdWords API Forum
Hi, 

You are right, it is not possible to generate the access token using the PHP client library. The library takes care of creating the access token and using that in the API call for each request. If you are specifically looking to generate the access token, you could generate that using the curl request given below: 

    -d refresh_token=you_refresh_token  \
    -d client_id=your-client-id  \
    -d client_secret=your-client-secret  \
    -d grant_type=refresh_token

Please check this forum thread for more details about the same discussion. 

Thanks,
Sreelakshmi, AdWords API Team
Reply all
Reply to author
Forward
0 new messages