Google API Oauth2: Only one refresh token for connected accounts
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));