Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:15:11+00:00 2026-06-14T17:15:11+00:00

Alright, I’m trying to set my application up with with the Google Drive SDK.

  • 0

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!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:15:13+00:00Added an answer on June 14, 2026 at 5:15 pm

    You don’t need to call generateAssertion(). Rather, just give the credentials to the client instance and let it do the work of generating the assertion

    $client = new Google_Client();
    $client->setAssertionCredentials($assertionCredentials);
    

    See http://code.google.com/p/google-api-php-client/wiki/OAuth2 for additional details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright I am practicing using cURL to login to different webservices. For this pariticular
Alright so I have no idea how to even begin doing this But basically
Alright, i have read many different views on how to do this with no
Alright, after doing a ton of research and trying almost every managed CPP Redist
Alright, Currently, if given a string like such: A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5,(F:0.6,G:0.7)H:0.8 I am using this: child
Alright so using Python with windows I am trying to run a batch command
Alright, this one's got me seriously stumped, after trying things out for hours with
Alright I am trying to set up an OAuth Provider in PHP, but I
Alright, I am trying to accomplish this: When a user clicks a button that
Alright, I'm trying to figure out why I can't understand how to do this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.