Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coaclient

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coaclient

Execute Node.js library for manage CourseraOAuth2 API tokens

  • 1.0.38
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-74.07%
Maintainers
1
Weekly downloads
 
Created
Source

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/

Clone project, open terminal, go to project directory, run in terminal 'npm install', you can find jar in $project_dir/target/ folder.

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 module)

  1. Clone project, go to project folder and build your own browser module by run command "browserify coaclient.js -o bundlecoaclient.js", after that you can use it at client side.

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

  1. Clone project and build your own module by run command "npm install" in cloned project dir.
  2. 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: :: var coaclientAPI = require('coaclient'); //import coaclient module into your module coaclientAPI().addClient(clientName, clientId, clientSecretKey, scope); coaclientAPI().generateAuthTokens(clientName); coaclientAPI().getAccessToken(clientName);

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

class CourseraOAuth2API

Methods: :: addClient(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".

:: deleteClient(String clientName);

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

:: generateAuthTokens(clientName);

By default starting server callback listener 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.

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

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

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

Keywords

FAQs

Package last updated on 21 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc