How can I use the Token Update (OAuth2) to get the user's RC list?

I installed this library - https://github.com/googleads/googleads-php-lib 
But I did not find the documentation for using this method 
<https://developers.google.com/adwords/api/docs/guides/clientlogin-to-oauth2-individual-accounts?hl=ru#retrieve_oauth_20_refresh_token_for_individual_adwords_account>
 
...

I use this code:

function Auth() {
    session_start();

    $oauth2 = new OAuth2([
        'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
        'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
        'redirectUri' => '***************',
        'clientId' => '***************',
        'clientSecret' => '***************',
        'scope' => 'https://www.googleapis.com/auth/adwords'
    ]);
    if (!isset($_GET['code'])) {
        // Create a 'state' token to prevent request forgery.
        // Store it in the session for later validation.
        $oauth2->setState(sha1(openssl_random_pseudo_bytes(1024)));
        $_SESSION['oauth2state'] = $oauth2->getState();

        // Redirect the user to the authorization URL.
        $config = [
            // Set to 'offline' if you require offline access.
            'access_type' => 'offline'
        ];
        header('Location: ' . $oauth2->buildFullAuthorizationUri($config));
        exit;
    }
    elseif (empty($_GET['state']) || ($_GET['state'] !== 
$_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
        exit('Invalid state.');
    } else {
        $d = $oauth2->setCode($_GET['code']);

        $authToken = $oauth2->fetchAuthToken();
        $oAuth2Credential = (new OAuth2TokenBuilder())
            ->fromFile()
            ->build();
        $session = (new AdWordsSessionBuilder())
            ->fromFile()
            ->withOAuth2Credential($oAuth2Credential)
            ->build();

        $adWordsServices = new AdWordsServices();

        $campaignService = $adWordsServices->get($session, 
CampaignService::class);
        define('PAGE_LIMIT',500);
        // Create selector.
        $selector = new Selector();
        $selector->setFields(['Id', 'Name']);
        $selector->setOrdering([new OrderBy('Name', SortOrder::ASCENDING)]);
        $selector->setPaging(new Paging(0, PAGE_LIMIT));

        $totalNumEntries = 0;
        do {
            // Make the get request.
            $page = $campaignService->get($selector);

            // Display results.
            if ($page->getEntries() !== null) {
                $totalNumEntries = $page->getTotalNumEntries();
                foreach ($page->getEntries() as $campaign) {
                    printf(
                        "Campaign with ID %d and name '%s' was found.\n",
                        $campaign->getId(),
                        $campaign->getName()
                    );
                }
            }

            // Advance the paging index.
            $selector->getPaging()->setStartIndex(
                $selector->getPaging()->getStartIndex() + PAGE_LIMIT
            );
        } while ($selector->getPaging()->getStartIndex() < $totalNumEntries);

        printf("Number of results found: %d\n", $totalNumEntries);
    }


In response, "Message: [AuthorizationError.USER_PERMISSION_DENIED @; 
trigger: ']"

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
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/95c92374-4f3c-4725-a254-7897a3e9db28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to