Permalink
Browse files

Sample oauth.php file, as suggested by @duckinator

  • Loading branch information...
1 parent 5378116 commit c38377f18da2f9aa5ebf0287b36f4ed38fb9521d @LeaVerou committed Dec 16, 2011
Showing with 36 additions and 1 deletion.
  1. +1 −1 index.html
  2. +34 −0 sample.oauth.php
  3. +1 −0 style.css
View
@@ -191,7 +191,7 @@
It uses <a href="http://leaverou.github.com/prefixfree" target="_blank">-prefix-free</a>,
so that you won't have to add any prefixes in your CSS code. You can save your work in
<a href="http://gist.github.com">Github gists</a>, embed it in other websites and share it
- with others.</p>
+ with others. <a href="http://twitter.com/dabblet">Follow @dabblet on twitter</a></p>
<p>It currently only supports modern versions of Chrome, Safari and Firefox but I'm hoping
to expand browser support soon.</p>
View
@@ -0,0 +1,34 @@
+<?php
+
+// This file should be the one's URL you give to Github as a callback
+
+$code = $_REQUEST['code'];
+
+$client_id = 'da931d37076424f332ef';
+$client_secret = 'YOUR_SECRET_HERE';
+
+if($code) {
+ $ch = curl_init('https://github.com/login/oauth/access_token');
+
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, "client_id=$client_id&client_secret=$client_secret&code=$code");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ 'Origin: http://dabblet.com'
+ ));
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+
+ $response = curl_exec($ch);
+
+ curl_close($ch);
+
+ if(preg_match('/access_token=([0-9a-f]+)/', $response, $matches)) {
+ $token = $matches[1];
+ }
+}
+?>
+<script>
+opener.gist.oauth[1]('<?= $token ?>');
+close();
+</script>
View
@@ -210,6 +210,7 @@ header {
z-index: 10;
padding: .4em .5em 0;
border-bottom: 10px solid black;
+ background: url(img/noise.png), linear-gradient(hsl(200, 10%, 20%), hsla(200, 10%, 20%, .8));
color: white;
line-height: 1.1;
font-weight: bold;

0 comments on commit c38377f

Please sign in to comment.