public function __construct(HttpClientInterface $httpClient = null) { parent::__construct($httpClient); $client_id = get_base64_secret('GITHUB_CLIENT_ID'); $client_secret = get_base64_secret('GITHUB_CLIENT_SECRET'); $this->authenticate($client_id, $client_secret, \Github\Client::AUTH_URL_CLIENT_ID); }
function get_secrets($service, $url) { // Check for '?' within URL and switch to '&' as needed // i.e. http://mydomain/myservice?param1=val1¶m2=val2 $delim = strpos($url, '?') !== FALSE ? '&' : '?'; switch ($service) { case 'facebook': return ''; case 'soundcloud': $key = get_base64_secret('SOUNDCLOUD_CLIENT_ID'); return $key ? $delim . 'client_id=' . $key : ''; case 'youtube': case 'google': $key = get_base64_secret('GOOGLE_KEY'); return $key ? $delim . 'key=' . $key : ''; break; case 'github': default: $client_id = get_base64_secret('GITHUB_CLIENT_ID'); $client_secret = get_base64_secret('GITHUB_CLIENT_SECRET'); return ($client_id ? $delim . 'client_id=' . $client_id : '') . ($client_secret ? '&client_secret=' . $client_secret : ''); } }