use client id/secret as authentication instead of oauth token since we can easily create a client id/secret for our Piwik Github organization but not an oauth token
This commit is contained in:
parent
4e84355a2e
commit
53ff50c989
3 changed files with 9 additions and 7 deletions
|
@ -17,10 +17,12 @@ define('PROJECT_NAME', 'Piwik');
|
|||
define('PROJECT_EMAIL', 'developer@piwik.org');
|
||||
|
||||
/**
|
||||
* See https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization for how to create a new token.
|
||||
* If you do not provide an OAuth2 Token you will be limited to 60 requests per hour instead of 5000.
|
||||
* You can create a new application on the application settings page: https://github.com/settings/applications/new .
|
||||
* After adding an application the client id and secret will be displayed.
|
||||
* If you do not provide a client id and secret you will be limited to 60 requests per hour instead of 5000.
|
||||
*/
|
||||
define('GITHUB_OAUTH_TOKEN', '');
|
||||
define('GITHUB_CLIENT_ID', '');
|
||||
define('GITHUB_CLIENT_SECRET', '');
|
||||
define('GITHUB_ORGANIZATION', 'piwik');
|
||||
define('GITHUB_REPOSITORY', 'piwik');
|
||||
define('NUMBER_OF_ISSUES_PER_PAGE', 100);
|
||||
|
|
|
@ -35,13 +35,13 @@ class GithubImporter {
|
|||
}
|
||||
}
|
||||
|
||||
public static function buildClient($oauthToken)
|
||||
public static function buildClient($clientId, $clientSecret)
|
||||
{
|
||||
$httpClient = new CachedGithubClient(array('cache_dir' => realpath('../tmp/github_api_cache')));
|
||||
$client = new Client($httpClient);
|
||||
|
||||
if ($oauthToken) {
|
||||
$client->authenticate($oauthToken, null, Client::AUTH_HTTP_TOKEN);
|
||||
if (!empty($clientId) && !empty($clientSecret)) {
|
||||
$client->authenticate($clientId, $clientSecret, Client::AUTH_URL_CLIENT_ID);
|
||||
}
|
||||
|
||||
return $client;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
require '../vendor/autoload.php';
|
||||
require '../config/config.php';
|
||||
|
||||
$client = helpers\GithubImporter::buildClient(GITHUB_OAUTH_TOKEN);
|
||||
$client = helpers\GithubImporter::buildClient(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET);
|
||||
$importer = new helpers\GithubImporter($client);
|
||||
|
||||
try {
|
||||
|
|
Reference in a new issue