OAuth

Application Flow

1. Redirect users to request Doper access
GET https://doper.io/login/oauth/authorize
Parameters
Name Type Description
client_id string Required. The client ID you received from Doper when you registered.
redirect_uri string Required. The URL in your application where users will be sent after authorization.
scope string Required. A comma delimited list of scopes.user, news, statuses, stories
state string An unguessable random string. It is used to protect against cross-site request forgery attacks..
Request:
https://doper.io/login/oauth/authorize?client_id=40db3eb6a5aefd3992a4&redirect_uri=http://yourdomain.com/callback&scope=user,news,statuses&state=xyz
Response:
http://yourdomain.com/callback&code=31ddae111e34c354a3af&state=xyz
2. Doper redirects back to your site
POST https://doper.io/login/oauth/access_token
Parameters
Name Type Description
client_id string Required. The client ID you received from Doper when you registered.
client_secret string Required. The client secret you received from Doper when you registered.
code string Required. The code you received as a response to Step 1.
redirect_uri string Required. The URL in your application where users will be sent after authorization.
state string An unguessable random string. It is used to protect against cross-site request forgery attacks..
Request:
curl -X POST \ -d "client_id=40db3eb6a5aefd3992a4" \ -d "client_secret=688a30e7a4f0823002f045ebe80597d2377c1d30" \ -d "code=31ddae111e34c354a3af" \ -d "redirect_uri=http://yourdomain.com/callback" \ -d "state=xyz" \ "https://doper.io/login/oauth/access_token"
Response:
{"access_token":"6fe04d2a08dffed4fc03f996b43c383000c2f3ce","scope":"user,news","token_type":"bearer"}
For example, in curl you can set the Authorization header like this:
curl -H "Authorization: token 6fe04d2a08dffed4fc03f996b43c383000c2f3ce" https://doper.io/api/user/dongri
Response:
{"profile":{"created":"2017-02-07T15:30:08.915989Z","full_name":"Dongri Jin","github":"dongri","qiita":"dongri","update":"2017-02-23T10:34:20.624745Z","user_name":"dongri"}}