Skip to content

Instantly share code, notes, and snippets.

@lotz84
Created July 27, 2014 03:01
Show Gist options
  • Save lotz84/534c4269f21e6822c59c to your computer and use it in GitHub Desktop.
Save lotz84/534c4269f21e6822c59c to your computer and use it in GitHub Desktop.
Gyazo OAuth test
request = require 'request'
express = require 'express'
app = express()
client =
id : "xxxx"
secret : "xxxx"
callback: "http://localhost:3000/callback"
app.get '/', (req, res) ->
res.redirect "https://api.gyazo.com/oauth/authorize?client_id=#{client.id}&redirect_uri=#{client.callback}&response_type=code"
app.get '/callback', (req, res) ->
request.post
url: "https://api.gyazo.com/oauth/token"
json: true
body:
client_id: client.id
client_secret: client.secret
redirect_uri: client.callback
code: req.query.code
grant_type: "authorization_code"
followAllRedirects: true
, (e, r, body) ->
res.json body
app.listen 3000
{
"name": "gyazo-node",
"version": "0.0.0",
"dependencies": {
"express": "~4.7.0",
"request": "~2.39.0"
},
"license": "BSD-2-Clause"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment