npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oauthic-youku

v0.2.0

Published

Yet another beautiful wrapped mikeal/request with OAuth 2.0 feature for Youku APIs.

Downloads

6

Readme

OAuthic for Youku

Build Status Coverage Status Dependency Status NPM version

Yet another beautiful wrapped mikeal/request with OAuth 2.0 feature for Youku.

Install

npm install oauthic-youku

Quick-start

Authorize

require('oauthic-youku').client({
    clientId: 'q298ajhzxkkp019cjzkoq01'
  , clientSecret: '228bnzokjpasiodufc'
  , redirectUri: 'https://my.server.com/callback'
  })
  .credentical(code, function (err, credentical, userInfo) {
    // ...
  })

Request

var client = require('oauthic-youku').client({
    clientId: 'q298ajhzxkkp019cjzkoq01'
  , clientSecret: '228bnzokjpasiodufc'
  })
  .token(accessToken, expiresAt)
  .refresh(refreshToken, function (refreshed, next) {
    // saveToDb(refreshed)
    return next()
  })
  .expired(function (token) {
    // log(token + ' has expired and could not be refreshed.')
  })

client.get('/videos/by_me', function (err, res, timeline) {
  // ...
})

oauthic.client(clientInfo)

Create a new client instance.

Arguments

  • clientInfo Object - Client informations
    • clientId String - App Key
    • clientScrect String - App Secret
    • redirectUri String - URL to be redirected to by the provider.

Returns

  • oauthic.Client - Client instance

Class: oauthic.Client

Client, a wrapped mikeal/request instance.

client.authorize([options])

Build the URL of the authorization page.

Arguments

  • options - Additional parameters

Returns

  • String - URL of the authorization page

client.credentical(code, callback)

Get Access Token with an Authorization Code and get ready for making a request.

Arguments

  • 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
      • refreshToken String - Refresh Token
    • userInfo Object - Additional user informations
      • id String - The user's unique ID
      • picture String - The URL of user's avatar picture
      • name String - The user's display name
      • _json - Object - Original JSON responsed

Returns

  • oauthic.Client - Client instance

client.token(accessToken[, expiresAt])

Set the Access Token.

Arguments

  • accessToken String - Access Token
  • expiresAt Date | Number - Optional. The time when Access Token expires

Returns

  • oauthic.Client - Client instance

client.refresh([refreshToken, ]onRefreshed)

Sets the Refresh Token and/or a handler that would be called when the Access Token is refreshed by the Refresh Token.

Arguments

  • refreshToken String - Refresh Token
  • onRefreshed(refreshed, done) Function - A handler that would be called when the Access Token is refreshed successfully by the Refresh Token. It's useful because you may want to save the new Access Token to the database
    • refreshed - Refreshed credenticals
      • accessToken String - The new Access Token
      • expiresAt Date - The time when the new Access Token expires
      • refreshToken String - The new Refresh Token
    • done([err]) Function - A callback that must be called to continue the flow after you have finished dealing with the new Token
      • err Error - Would be an error object

Returns

  • oauthic.Client - Client instance

client.expired(onExpired)

Registers a handler that would be called when the Access Token is expired and could not be refreshed.

Arguments

  • onExpired(token) Function - Handler function
    • token String - The expired Access Token

client.get(uri[, options][, callback]), client.post(uri[, options][, callback])

Wrapped methods from mikeal/request. General parameters (e.g. access token) is added. URL could be written in short form, e.g. /mirror/v1/timeline for https://www.youkuapi.com/mirror/v1/timeline.

Errors

  • TokenExpiredError - The Access Token is expired and could not be refreshed
  • EndpointError - Error from API endpoint

client.accessToken

  • String

Returns the current user's Access Token. Useful when you'd prefer building request parameters manually.

Properties

  • token String - The expired Access Token

License

(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.