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

coaclient

v1.0.51

Published

Execute Node.js library for manage CourseraOAuth2 API tokens

Downloads

45

Readme

Coursera OAuth2 client

This project is a Node.js library consisting of a client for interacting with Coursera's OAuth2 authorizes APIs.

Requirements

Install Node.js from https://nodejs.org/en/download/

Setup

Before using Coursera's OAuth2 APIs, be sure you know your client id, client secret, and scopes you want for your application. You may create an application at https://accounts.coursera.org/console. When creating the application, set the Redirect URI to be http://localhost:9876/callback?client_id=<your_client_id>.

Usage

(Client-side)

  • Clone project, go to the project folder and build module by run command 'browserify coaclient.js -o bundlecoaclient.js', after that you can use it at client side.

(Server-side) You can use module in different ways:

  • Clone project, add this module to your project, then run command 'npm install' to fetch all dependencies.
  • Open terminal, go to your project folder and download module from npm global repository via command 'npm install coaclient' after you can use it in your project:

// import module
var Coaclient = require('coaclient');
// use static methods
Coaclient.addClientConfig(clientName, clientId, clientSecretKey, scope);
Coaclient.generateAuthTokens(clientName);
Coaclient.getAccessToken(clientName).then(function (tokens) {
   // do something with 'tokens';
}).catch(function (error) {
   // do something if catch error;
});

The Coaclient tries to open the default system browser. The application configuration will be saved to the local file if the request is succeeded. You should check the data you've provided to the library during application configuration if you see any errors in the browser.

If the client was successfully added and configured, you will be able to successfully get authentication tokens for Coursera API. Otherwise, an exception will be thrown telling you to set up your application for API access.

Documentation

Methods:


addClientConfig(clientName, clientId, clientSecretKey, scope);

Create a new client config and save it to the local config file: <home.dir>/.coursera/coaconfig.csv

Parameters:

clientName - Client Name
clientId - Coursera Client ID
clientSecret - Coursera Client Secret Key
scope - by default used "view_profile", for business use "access_business_api".

deleteClientConfig(clientName);

Delete client config from file: <home.dir>/.coursera/coaconfig.csv


generateAuthTokens(clientName);

By default start-server callback listener on port 9876 and get auth tokens from Coursera OAuth API.


getAuthTokens(clientName).then(function (tokens) {
    // do something with 'tokens';
}).catch(function (error) {
    // do something if catch error;
});

Returns: Promise object with refresh, access tokens and expired time from auth token file: <home.dir>/.coursera/<client_name>_oauth2.csv.


getAccessToken(clientName).then(function (accessToken) {
    // do something with 'accessToken';
}).catch(function (error) {
    // do something if catch error;
});

Returns: Promise object with access token from auth token file: <home.dir>/.coursera/<client_name>_oauth2.csv.


getClientConfigs.then(function (listOfClientConfigs) {
    // do something with 'listOfClients';
}).catch(function (error) {
    // do something if catch error;
});

Returns: Promise object with a list of client configs from local file: <home.dir>/.coursera/coaconfig.csv.


getClientConfig(clientNameOrId).then(function (clientConfig) {
    // do something with 'clientConfig';
}).catch(function (error) {
    // do something if catch error;
});

Returns: Promise object with client config from local file: <home.dir>/.coursera/coaconfig.csv.


Bugs / Issues / Feature Requests

Please use the Github issue tracker to document any bugs or other issues you encounter while using this tool.