Yet another beautiful wrapped mikeal/request with OAuth 2.0 feature for Sina Weibo.
npm install oauthic-weibo
require('oauthic-weibo')
.client(clientInfo)
.credentical(code, function (err, credentical, userInfo) {
// ...
})
var client = require('oauthic-weibo').client(clientInfo)
.token(accessToken, expiresAt)
.expired(onExpired)
client.get('/statuses/user_timeline.json', function (err, res, timeline) {
// ...
})
Create a new client instance.
- clientInfo Object - Client informations
- clientId String - App Key
- clientScrect String - App Secret
- redirectUri String - URL to be redirected to by the provider.
- oauthic.Client - Client instance
Client, a wrapped mikeal/request instance.
Build the URL of the authorization page.
- options - Additional parameters
- scope String | Array - Additional scopes. Should be an array or a string separated by
,
- state String - A parameter that would be in the query string in
redirectUri
. It's useful in avoiding CSRF attacking - display String - Determine how the authorization page would looks. Should be:
- default - For desktop browsers
- mobile - For mobile devices
- wap - For cellphones that support WAP only
- client - For desktop clients
- forcelogin Boolean - Determine whether to force a login.
- language String - Language of the authorization page. Would be Simplified-Chinese without this parameter. For English set it to
en
.
- scope String | Array - Additional scopes. Should be an array or a string separated by
- String - URL of the authorization page
Get Access Token with an Authorization Code and get ready for making a request.
- code String - Authorization Code
- callback(err, credentical, userInfo) Function - Callback
- err Error | null - Error object
- credentical Object - Token informations
- accessToken String - Access Token
- expiresAt Date - The time when Access Token expires
- userInfo Object - Additional user informations
- id String - The user's unique ID
- picture String - The URL of user's avatar picture
- ...
- oauthic.Client - Client instance
Set the Access Token.
- accessToken String - Access Token
- expiresAt Date | Number - Optional. The time when Access Token expires
- oauthic.Client - Client instance
Registers a handler that would be called when the Access Token is expired and could not be refreshed.
- onExpired(token) Function - Handler function
- token String - The expired Access Token
Wrapped methods from mikeal/request. General parameters (e.g. access token) is added. URL could be written in short form, e.g. /statuses/update.json
for https://api.weibo.com/2/statuses/update.json
.
Actually, Sina Weibo supports GET and POST only, so other methods is not tested or documented.
- oauthic.TokenExpiredError - The Access Token is expired and could not be refreshed
- String
Returns the current user's Access Token. Useful when you'd prefer building request parameters manually.
Occurs when the Access Token is expired and could not be refreshed.
- token String - The expired Access Token
(The MIT License)
Copyright (c) 2013 XiNGRZ <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.