From 32282e7461bb12ff2e8c7684ad896cbb471200a2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 18 Oct 2012 17:08:34 +0200 Subject: [PATCH] Add hostname to the OAuth app name --- src/Composer/Repository/Vcs/GitHubDriver.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 1f09a595a..bbe75f70f 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -355,11 +355,21 @@ class GitHubDriver extends VcsDriver $password = $this->io->askAndHideAnswer('Password: '); $this->io->setAuthorization($this->originUrl, $username, $password); + // build up OAuth app name + $appName = 'Composer'; + if (0 === $this->process->execute('hostname', $output)) { + $appName .= ' on ' . trim($output); + } + $contents = JsonFile::parseJson($this->remoteFilesystem->getContents($this->originUrl, 'https://api.github.com/authorizations', false, array( 'http' => array( 'method' => 'POST', 'header' => "Content-Type: application/json\r\n", - 'content' => '{"scopes":["repo"],"note":"Composer","note_url":"https://getcomposer.org/"}', + 'content' => json_encode(array( + 'scopes' => array('repo'), + 'note' => $appName, + 'note_url' => 'https://getcomposer.org/', + )), ) ))); } catch (TransportException $e) {