Socket
Book a DemoInstallSign in
Socket

@cumulus/earthdata-login-client

Package Overview
Dependencies
Maintainers
9
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cumulus/earthdata-login-client

A client for the Earthata Login service API

latest
Source
npmnpm
Version
9.0.1
Version published
Weekly downloads
9
-68.97%
Maintainers
9
Weekly downloads
 
Created
Source

@cumulus/earthdata-login-client

Utilities for OAuth authentication using NASA Earthdata Login.

Versioning

Cumulus uses a modified semantic versioning scheme and minor releases likely include breaking changes.

Before upgrade, please read the Cumulus release notes before upgraded.

It is strongly recommended you do not use ^ in your package.json to automatically update to new minor versions. Instead, pin the version or use ~ to automatically update to new patch versions.

Installation

$ npm install @cumulus/earthdata-login-client

Usage

const { EarthdataLoginClient } = require('@cumulus/earthdata-login-client');

const client = new EarthdataLogin({
  clientId: 'my-client-id',
  clientPassword: 'my-client-password',
  earthdataLoginUrl: 'https://earthdata.login.nasa.gov',
  redirectUri: 'http://my-api.com'
});

API

EarthdataLoginClient

A client for the Earthdata Login API

Kind: global class

new EarthdataLoginClient(params)

ParamTypeDescription
paramsObject
params.clientIdstringsee example
params.clientPasswordstringsee example
params.earthdataLoginUrlstringsee example
params.redirectUristringsee example

Example

const oAuth2Provider = new EarthdataLogin({
  clientId: 'my-client-id',
  clientPassword: 'my-client-password',
  earthdataLoginUrl: 'https://earthdata.login.nasa.gov',
  redirectUri: 'http://my-api.com'
});

earthdataLoginClient.getAuthorizationUrl([state]) ⇒ string

Get a URL of the Earthdata Login authorization endpoint

Kind: instance method of EarthdataLoginClient
Returns: string - the Earthdata Login authorization URL

ParamTypeDescription
[state]stringan optional state to pass to Earthdata Login

earthdataLoginClient.getAccessToken(authorizationCode) ⇒ Promise.<Object>

Given an authorization code, request an access token and associated information from the Earthdata Login service.

Returns an object with the following properties:

  • accessToken
  • refreshToken
  • username
  • expirationTime (in seconds)

Kind: instance method of EarthdataLoginClient
Returns: Promise.<Object> - access token information

ParamTypeDescription
authorizationCodestringan OAuth2 authorization code

earthdataLoginClient.refreshAccessToken(refreshToken) ⇒ Promise.<Object>

Given a refresh token, request an access token and associated information from the Earthdata Login service.

Returns an object with the following properties:

  • accessToken
  • refreshToken
  • username
  • expirationTime (in seconds)

Kind: instance method of EarthdataLoginClient
Returns: Promise.<Object> - access token information

ParamTypeDescription
refreshTokenstringan OAuth2 refresh token

earthdataLoginClient.getTokenUsername(params) ⇒ Promise.<string>

Query the Earthdata Login API for the UID associated with a token

Kind: instance method of EarthdataLoginClient
Returns: Promise.<string> - the UID associated with the token

ParamTypeDescription
paramsObject
params.onBehalfOfstringthe Earthdata Login client id of the app requesting the username
params.tokenstringthe Earthdata Login token
[params.xRequestId]stringa string to help identify the request in the Earthdata Login logs

About Cumulus

Cumulus is a cloud-based data ingest, archive, distribution and management prototype for NASA's future Earth science data streams.

Cumulus Documentation

Contributing

To make a contribution, please see our contributing guidelines.

Generated automatically using npm run build-docs

Keywords

Cumulus

FAQs

Package last updated on 07 May 2021

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