diff --git a/src/config/config.php b/src/config/config.php index 2335234..3f82125 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -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); diff --git a/src/helpers/GithubImporter.php b/src/helpers/GithubImporter.php index 346fb9b..974b84f 100755 --- a/src/helpers/GithubImporter.php +++ b/src/helpers/GithubImporter.php @@ -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; diff --git a/src/tasks/import_github_issues.php b/src/tasks/import_github_issues.php index 862171f..bc7875c 100644 --- a/src/tasks/import_github_issues.php +++ b/src/tasks/import_github_issues.php @@ -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 {