Posts tagged with google-oauth

I followed this guide to create a web app flow for authenticating users with Google.

Despite listing https://www.googleapis.com/auth/adwords in the scope parameter, I don't get a gapi.client.adwords or anything like that once the authentication is complete. I am unable to retrieve any information about the user's MCC/AdWords/Ad Manager accounts.

I've tried using gapi.client.request() but I can't seem to find the arguments that I should pass for access to the AdWords API.

I'm trying to do something like this:

let __req = gapi.client.request({   method: "GET",   path: "/adwords/v?/???",   params: { fields: "???" } }); __req.execute(function(response) {   console.log(response); }); 

... or like this:

console.log(gapi.client.adwords) 

but I can't figure out what I need to pass to gapi.client.request and gapi.client.adwords doesn't exist.

Is it possible that I'm not passing a discoveryDoc or something like that? Where is the discoveryDoc for AdWords?

scope:   "https://www.googleapis.com/auth/adwords", discoveryDocs: ["???"] 

Use Case: I'm trying to get a list of MCC/AdWords/Ad Manager accounts (specifically their ID's and names) that are associated with (or owned by) the authenticated user.

Thanks in advance!

I am using the Google Oauth2 API to connect to Google Ads and become only one refresh token when my @gmail.com account has read access to two different Google Ads accounts.

I have the account a@gmail.com. This account has read access to the Google Ads accounts b@gmail.com and c@gmnail.com.

When I create two connections to Google Ads with the email a@gmail.com for the accounts b@gmail.com and c@gmail.com, then I receive only one refresh token, for the first connection and none refresh token for the second connection. Why? How can I manage this, to become 2 refresh tokens for each connection? The only way to become a refresh token for the second connection is to go to my account a@gmail.com and to decline the access to my app manually and connect again with c@gmail.com. But then b@gmail.com has no refresh token anymore.

code:

$oauth2 = new OAuth2(             [                 'authorizationUri' => $this->container->getParameter('oauth2.google.adwords.authorizationUri'),                 'tokenCredentialUri' => $this->container->getParameter('oauth2.google.adwords.tokenCredentialUri'),                 'redirectUri' => $this->container->getParameter('domain.system') . $this->container->getParameter(                         'oauth2.google.adwords.redirectUri.advertiser'                     ),                 'clientId' => $this->container->getParameter('oauth2.google.adwords.clientId'),                 'clientSecret' => $this->container->getParameter('oauth2.google.adwords.clientSecret'),                 'scope' => $this->container->getParameter('oauth2.google.adwords.scope')             ]         ); // Create a 'state' token to prevent request forgery.             // Store it in the session for later validation.             $randomState = sha1(openssl_random_pseudo_bytes(1024)) . '---' . $accountId;             $oauth2->setState($randomState);             // Redirect the user to the authorization URL.             $config = [                 // Set to 'offline' if you require offline access.                 'access_type' => 'offline',                 'approval_prompt' => 'force'             ];             // redirect to google ads             return new RedirectResponse($oauth2->buildFullAuthorizationUri($config));