Before starting with code, an application has to be registered with GitHub. This is done by visiting account settings, and then developer settings.
An application must be created to acquire a clientid and clientsecret. Creation of the application requires a homepage URL and an authorization callback URL. Both should be set to http://localhost. This does not have to be a valid web service for the purposes of this example; it is used to acquire the authorization code in a web browser.
The values from the web page will fill the following variables:
$clientId = 'FromGitHub' $clientSecret = 'FromGitHub'