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

  • Home
  • SEARCH
  • 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 8343397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:03:00+00:00 2026-06-09T06:03:00+00:00

I’m getting the following errors when trying to use OATH2 to authenticate against the

  • 0

I’m getting the following errors when trying to use OATH2 to authenticate against the Google Analytics API (v3):

Warning: openssl_sign() expects parameter 4 to be long, string given in google-api-php-client/src/auth/Google_P12Signer.php on line 60

Google_AuthException: Unable to sign data in google-api-php-client/src/auth/Google_P12Signer.php on line 61

Here’s my PHP code:

// api dependencies
require_once(dirname(__FILE__) . '/../../vendor/google-api-php-client/src/Google_Client.php');
require_once(dirname(__FILE__) . '/../../vendor/google-api-php-client/src/contrib/Google_AnalyticsService.php');

session_start();

// create client object and set app name
$client = new Google_Client();
$client->setApplicationName(APP_NAME);

// set assertion credentials
$client->setAssertionCredentials(
  new Google_AssertionCredentials(
    'xxxxxxx@developer.gserviceaccount.com',
    array('https://www.googleapis.com/auth/analytics.readonly'),
          file_get_contents('xxxxxxxxxx-privatekey.p12')  // keyfile
));

// other settings
$client->setClientId('xxxxxxx.apps.googleusercontent.com');
$client->setAccessType('offline_access');

// create service
$service = new Google_AnalyticsService($client);

$properties = $service->management_webproperties->listManagementWebproperties("~all");
print_r($properties);

if I print_r($service) I get a valid object with no errors. It is the listManagementWebproperties() call that generates the errors.

Does anyone please have a solution? It looks like the Google_Client might be in flux, since it was edited just a couple of days ago. I obtained it from trunk via SVN, NOT via the download page which I believe has an older version that does not support service accounts. Thanks.

  • 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-09T06:03:02+00:00Added an answer on June 9, 2026 at 6:03 am

    According to the openssl_sign() PHP documentation, the 4th parameter should be an int.

    http://php.net/manual/en/function.openssl-sign.php

    bool openssl_sign ( string $data , string &$signature , mixed $priv_key_id [, int $signature_alg = OPENSSL_ALGO_SHA1 ] )
    

    In the code for Google_P12Signer they are using it like this:

    if (!openssl_sign($data, $signature, $this->privateKey, "sha256")) {
      throw new Google_AuthException("Unable to sign data");
    }
    

    Passing “sha256” which is obviously not an INT. There isn’t an OPENSSL_ALGO_* defined for sha256 according to this: http://www.php.net/manual/en/openssl.signature-algos.php which means it won’t work.

    What you will have to do is define your own OPENSSL_ALGO_SHA256, sort of like you see in this code: http://pastebin.com/qdCyC0Pe

    Someone wrote a patch to help also: http://php.it2y.info/missing-sha256-sha512-families-of-signature-algorithms.html

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.