Socket
Socket
Sign inDemoInstall

ebay-oauth-nodejs-client

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ebay-oauth-nodejs-client

Get oauth2 token for ebay developer application


Version published
Weekly downloads
6.6K
increased by11.76%
Maintainers
1
Install size
43.4 kB
Created
Weekly downloads
 

Readme

Source

Ebay Oauth API

This code allows developers to fetch an OAuth token that can be used to call the eBay Developer REST APIs. The code is intended for use with Node.js.

npm version

Table of Contents

What is OAuth

OAuth 2.0 is the most widely used standard for authentication and authorization for API based access. The complete end to end documentation on how eBay OAuth functions may be used is available at developer.ebay.com. See e.g.,https://developer.ebay.com/api-docs/static/oauth-tokens.html

Installation

npm install ebay-oauth-nodejs-client

or

yarn add ebay-oauth-nodejs-client

Library Setup and getting started

  1. Invoke the outh ebay library as given below
const EbayAuthToken = require('ebay-oauth-nodejs-client');
const ebayAuthToken = new EbayAuthToken({
    filePath: 'demo/eBayJson.json' // input file path.
})
  1. If you want to get your application credentials such as AppId, DevId, and CertId. Refer to Creating eBay Developer Account for details on how to get these credentials.
  2. You can refer to example.js for an example of how to use credentials.
  3. For Authorization code grant
    1. Get User consent url using ebayAuthToken.generateUserAuthorizationUrl()
    2. Open the generateUserAuthorizationUrl in the browser, which allows you to login in to ebay site. You will get a authorization code, or if you are using express, use res.direct(generateUserAuthorizationUrl);
    3. Pass the authorization code retrieved in the above step to exchangeCodeForAccessToken method using ebayAuthToken.exchangeCodeForAccessToken(environment, code)

Configure credentials

Create a config JSON file in your application. The config file should contain your eBay applications keys: App Id, Cert Id & Dev Id. A sample config file is available at demo/ebay-config-sample.json. Learn more about creating application keys.

{
    "SANDBOX": {
        "clientId": "---Client Id---",
        "clientSecret": "--- client secret---",
        "devid": "-- dev id ---",
        "redirectUri": "-- redirect uri ---",
        "baseUrl": "api.sandbox.ebay.com" //don't change these values
    },
    "PRODUCTION": {
        "clientId": "---Client Id---",
        "clientSecret": "--- client secret---",
        "devid": "-- dev id ---",
        "redirectUri": "-- redirect uri ---",
        "baseUrl": "api.ebay.com" //don't change these values
    }
}

Types of Tokens

There are mainly two types of tokens in usage.

Application Token

An application token contains an application identity which is generated using client_credentials grant type. These application tokens are useful for interaction with application specific APIs such as usage statistics etc.,

User Token

A user token (access token or refresh token) contains a user identity and the application’s identity. This is usually generated using the authorization_code grant type or the refresh_token grant type.

Supported Grant Types for OAuth

All of the regular OAuth 2.0 specifications such as client_credentials, authorization_code, and refresh_token are supported. Refer to eBay Developer Portal

Client Credentials

This grant type can be performed by simply using ebayAuthToken.getApplicationToken(). Read more about this grant type at oauth-client-credentials-grant.

Authorization Code

This grant type can be performed by a two step process. Call ebayAuthToken.generateUserAuthorizationUrl(environment, scopes, state) to get the Authorization URL to redirect the user to. Once the user authenticates and approves the consent, the callback needs to be captured by the redirect URL setup by the app and then call ebayAuthToken.exchangeCodeForAccessToken(environment, code) to get the refresh and access tokens.

Read more about this grant type at oauth-authorization-code-grant.

Refresh Token

This grant type can be performed by simply using ebayAuthToken.getAccessToken(environment, refreshToken, scopes). Usually access tokens are short lived and if the access token is expired, the caller can use the refresh token to generate a new access token. Read more about it at Using a refresh token to update a user access token

Developers and Contributors

Ajaykumar Prathap Sandeep Dhiman Sree Kalahasthi

References

  1. https://developer.ebay.com/api-docs/static/oauth-tokens.html

  2. https://developer.ebay.com/api-docs/static/oauth-quick-ref-user-tokens.html

  3. https://developer.ebay.com/api-docs/static/oauth-gen-app-token.html

  4. https://developer.ebay.com/my/keys

License

Copyright (c) 2019 eBay Inc.

Use of this source code is governed by a Apache-2.0 license that can be found in the LICENSE file or at https://opensource.org/licenses/Apache-2.0.

Getting Client Id and Client Secret

https://developer.ebay.com/api-docs/static/oauth-credentials.html

Getting your redirect_uri value

https://developer.ebay.com/api-docs/static/oauth-redirect-uri.html

Specifying right scopes

https://developer.ebay.com/api-docs/static/oauth-scopes.html

Keywords

FAQs

Last updated on 09 Nov 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc