I am having trouble authenticating myself using the DoubleClick Bid Manager API I have set up a service account as per Google's instructions and am using the Google APIs PHP client library. Following the documentation, my code looks like this:
require_once 'Google/autoload.php';
$client_email = 'myemail.com';
$private_key = file_get_contents('myfilename.p12');
$scopes = ['https://www.googleapis.com/auth/doubleclickbidmanager'];
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key,
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_DoubleClickBidManager($client);
$response = $service->queries->listqueries();
The last line provokes an error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/doubleclickbidmanager/v1/queries: (403) You are not authorized to use DoubleClick Bid Manager API. Please contact bidmanager-support@google.com.'
I have emailed them but I'm not sure if there is any one there providing support for technical questions. I've reread the documentation, I can't see where I am going wrong. If anyone has been through this before or has any pointers, they will be much appreciated!!!
Many thanks
PS I set up my API access earlier this week. Again, I followed the instructions in the documentation and received the last confirmation email from Google regarding setup, so everything should be good to go in that respect as well