Skip to content

Instantly share code, notes, and snippets.

Avatar

Pepijn van den Berkhof Pepijn1908

View GitHub Profile
@Pepijn1908
Pepijn1908 / github-oauth2-client.php
Last active Jul 4, 2017 — forked from aaronpk/github-oauth2-client.php
Simple PHP example of using Github's OAuth 2 API
View github-oauth2-client.php
<?php
define('OAUTH2_CLIENT_ID', 'YOUR APP CLIENT ID HERE');
define('OAUTH2_CLIENT_SECRET', 'YOUR APP CLIENT SECRET HERE');
$authorizeURL = 'https://github.com/login/oauth/authorize';
$tokenURL = 'https://github.com/login/oauth/access_token';
$apiURLBase = 'https://api.github.com/';
session_start();
// Start the login process by sending the user to Github's authorization page
if(isset($_GET['action']) && $_GET['action'] == 'login'){
// Generate a random hash and store in the session for security
You can’t perform that action at this time.