9.0.1 • Published 3 years ago

@cumulus/earthdata-login-client v9.0.1

Weekly downloads
164
License
Apache-2.0
Repository
github
Last release
3 years ago

@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
statestringan 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.xRequestIdstringa 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

8.1.2

3 years ago

8.1.1

3 years ago

8.1.0

3 years ago

9.0.1

3 years ago

9.0.0

3 years ago

8.0.0

3 years ago

6.0.1

3 years ago

7.2.0

3 years ago

7.1.0

3 years ago

7.0.0

3 years ago

6.0.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

4 years ago

3.0.1

4 years ago

2.0.8

4 years ago

3.0.0

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.24.0-alpha.0

4 years ago