Alright, I'm trying to set my application up with with the Google Drive SDK. I am using it as a service account, so the set up is a little different. This is how I am doing things:
including required files:
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/auth/Google_AssertionCredentials.php';
require_once "google-api-php-client/src/contrib/Google_Oauth2Service.php";
define constants:
DEFINE("TRUE_PATH",$_SERVER["DOCUMENT_ROOT"].'path/to/file');
DEFINE("SERVICE_ACCOUNT_EMAIL","somecode@developer.gserviceaccount.com");
DEFINE("DRIVE_SCOPE","https://www.googleapis.com/auth/drive");
the function:
function generateAssertion() {
$assertionCredentials = new Google_AssertionCredentials();
$assertionCredentials->serviceAccountName='somecode@developer.gserviceaccount.com';
$assertionCredentials->privateKey=
TRUE_PATH.'9e01fd1414aa082fadeec316161eb7028558fbde-privatekey.p12';
$assertionCredentials->privateKeyPassword = 'notasecret';
$p12cert = array();
$file = TRUE_PATH.'9e01fd1414aa082fadeec316161eb7028558fbde-privatekey.p12';
if (file_exists($file)) {
try {
$assertion = $assertionCredentials->generateAssertion();
return $assertion;
} catch (Exception $e) {
d($assertionCredentials);
return 'Caught exception: ' . $e->getMessage() . "\n";
}
} else {
return "no p12 privatekey file";
}
}
the line $assertion = $assertionCredentials->generateAssertion(); gives me a code that loooks like this:
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJodHRwczpcL1wvYWNjb3VudHMuZ29vZ2xlLmNvbVwvb1wvb2F1dGgyXC90b2tlbiIsInNjb3BlIjpudWxsLCJpYXQiOjEzNTMzNjk3NzUsImV4cCI6MTM1MzM3MzM3NSwiaXNzIjoiMjY5Mjg1NDU2NjY0QGRldmVsb3Blci5nc2VydmljZWFjY291bnQuY29tIn0.KMBTsGZkhLhddBFtc0PB1qZgtdQYyirhWtYixCYx1zo5Otv9pCUBfvrCXOg3JzR-mzE6zHuCZdmGOD7w_LRwYHJpoo0rdpxDXLjtNCgFZdu1d21cVAnqTkIhMGvdS_K7JP_KioXyi-nBdvZt9IXKaApIdDKhRp-T5HByIeO2ijU
my question is, what do I do with the code/token returned from generateAssertion() so that I can access my drive account?
I tried using it as an access token and a refresh token with no success.
I apologize if this is a stupid question, but I am new to the sdk
Any help will be greatly appreciated.
Thank you!!!