Google-api-php-client: Let passing client_secret file content as string to authentication config method

Created on 18 Nov 2016  路  3Comments  路  Source: googleapis/google-api-php-client

I'm updating a legacy App to use some Google service so I'm enforced to read Auth Client data from a custom config file which include other App settings instead of read it from _client_secret_XXX.json_ file downloaded from Google developer console. So I copied and pasted the content of file _client_secret_XXX.json_ to my custom config file under certain key, e.g. _google_client_ then configured the client as follow:

$client_data = json_decode($custom_config['google_client'], true);
$client = new Google_Client();
$client->setClientId($client_data['web']['client_id']);
$client->setClientSecret($client_data['web']['client_secret']);
//Set here other data from config file like: RedirectUri, etc.

And it works fine but I think it is not a best practice because the file _client_secret_XXX.json_ may contain many other data and Google's PHP client library is the guy that know the proper way to set up the client with those information so the developers should rely on:

$client->setAuthConfig('client_secret_XXX.json');

just like the basic example looks in README.md on github.

I can't find any method on the library to pass the file content as string, something like this:

$client->setAuthConfigContent($custom_config['google_client']);

So consider a possible enhancement or please share a way to pass the file content as string to the client library to let it configures the client object properly.

Notes:

  • setAuthConfig() and setAuthConfigFile() methods expect a file name, not the file content.
  • I'm using the latest PHP client library (2.1.0) at the moment this question was posted.
feature request

Most helpful comment

use the constructor
$config = [
'client_secret' => $credentials['client_secret']->web->client_secret,
'client_id' => $credentials['client_secret']->web->client_id,
'redirect_uri' => $credentials['client_secret']->web->redirect_uris[0]
];
$client = new Google_Client($config);

All 3 comments

hi! any updates?

use the constructor
$config = [
'client_secret' => $credentials['client_secret']->web->client_secret,
'client_id' => $credentials['client_secret']->web->client_id,
'redirect_uri' => $credentials['client_secret']->web->redirect_uris[0]
];
$client = new Google_Client($config);

Thank you for your feature request. This client library is currently in maintenance mode. We are fixing necessary bugs and adding essential features to ensure this library continues to meet your needs for accessing Google APIs. After careful consideration, we have decided not to proceed with this enhancement. If you disagree, please feel free to re-open this issue and explain why you believe it is essential for users of this client library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexandreGerault picture AlexandreGerault  路  5Comments

whatido1 picture whatido1  路  3Comments

kungufli picture kungufli  路  3Comments

unixkapl picture unixkapl  路  3Comments

ysaurabh33 picture ysaurabh33  路  3Comments