{"_id":"@claytonfbell/ebay-oauth-nodejs-client","name":"@claytonfbell/ebay-oauth-nodejs-client","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@claytonfbell/ebay-oauth-nodejs-client","version":"0.0.1","description":"Get oauth2 token for ebay developer application","main":"dist/index.js","scripts":{"lint":"eslint .","test":"eslint . && mocha","build":"tsc --build","clean":"tsc --build --clean"},"author":{"name":"Ajaykumar Prathap"},"license":"ISC","contributors":[],"keywords":["eBay","Oauth2","Oauth-ebay","Oauth-token","Authentication","access token","refresh token","oauth-ebay","oauthebaynode"],"dependencies":{"querystring":"^0.2.0"},"devDependencies":{"@types/node":"^17.0.35","chai":"^4.2.0","eslint":"^6.8.0","eslint-config-ebay":"^1.1.1","mocha":"^6.1.4","nock":"^10.0.6","typescript":"^4.6.4"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/eBay/ebay-oauth-nodejs-client.git"},"types":"./dist/index.d.ts","gitHead":"89f859098ddd0f6bd3140a0a58a53e4f6d73d73b","bugs":{"url":"https://github.com/eBay/ebay-oauth-nodejs-client/issues"},"homepage":"https://github.com/eBay/ebay-oauth-nodejs-client#readme","_id":"@claytonfbell/ebay-oauth-nodejs-client@0.0.1","_nodeVersion":"16.13.0","_npmVersion":"8.1.3","dist":{"integrity":"sha512-SQA0GMnBty/qft8SR4xlKf5vd9QfNYqnQoCj9CNNi01mtT/D452ImN6ITmYjQiZ/q2zgh/fWBvfA+4ILE35QfA==","shasum":"f79537cc37cd5e6f096fa4632e47d13c8e230fb4","tarball":"https://registry.npmjs.org/@claytonfbell/ebay-oauth-nodejs-client/-/ebay-oauth-nodejs-client-0.0.1.tgz","fileCount":27,"unpackedSize":60935,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbnun+Z0+RVoSshkVCpnV/TxO0GU2Qidl5pP3qYvrCgAIgLdfU+NqIDmvyzSOMqGCxXGGhWsu5Fh6+IOXOF6LHlMY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiiUMMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEoA/+Lf2NHtSX7iqbgaBxyn/J+ywMi7+DUSr5BPi5eca/gKts0knJ\r\nZHO6eZhOQVrQGZyyyLaitQB7lNWomY+2uzbdQK9jTYujjOq/Rw65j40/NfrD\r\n7PtFL6pmxVHRQB+ISpDJHqT4axWWNl51jjiBFpApyAdZDf69KvTqglwVVIHb\r\nopU8jYkfVmUUQyFP5kwXYYVnVbRWxMwKdq66EA9dQS34oPR0frwj3Azeam77\r\nWrEg9uUYXgfHCfVTmJUF0KiU5G+N+hlj1gagrnT9bdJ1hbAyGEI0AjCPsrQ5\r\nYiGWKzfJdDoPpQq4bck/mwuxjgZQq+caE+hzNeDEJ49H2SMSP99BMErrG5qW\r\n8P9wCmnZ20rPT5mvcelFz5iiUDE/ELrQKWhYWOMVn+8iLsV8IXMtdfzZyodG\r\nJ3nbF0LZSOeZYLtzbakbcJW5KLl/4yxFbKZtDW8Y/c7qu/am0IKGIhrZJ25B\r\nLq1F7lBNQ8sPK4SJr6pNd2aAk9xUuQTPIrRup5R5K/XpzGUQCBZseazmg01Q\r\nAifNMWPVMWZzeR41FVuoJ8sOotvgqO0D4hJsVsjRFGz8UqoOnvPyARq54DTb\r\n9Rn6LGm4DF/I42SgbI6mIPGDKH5laqUgIcbsyI0N9ieOzylRzNPvAkLYhUOy\r\njLiR9M40i6keBMSO67zwUs4OsEOIM5PPhjQ=\r\n=Vgmp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"claytonfbell","email":"claytonfbell@gmail.com"},"directories":{},"maintainers":[{"name":"claytonfbell","email":"claytonfbell@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ebay-oauth-nodejs-client_0.0.1_1653162764251_0.1438676257893483"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-21T19:52:44.195Z","0.0.1":"2022-05-21T19:52:44.393Z","modified":"2022-05-21T19:52:44.532Z"},"maintainers":[{"name":"claytonfbell","email":"claytonfbell@gmail.com"}],"description":"Get oauth2 token for ebay developer application","homepage":"https://github.com/eBay/ebay-oauth-nodejs-client#readme","keywords":["eBay","Oauth2","Oauth-ebay","Oauth-token","Authentication","access token","refresh token","oauth-ebay","oauthebaynode"],"repository":{"type":"git","url":"git+https://github.com/eBay/ebay-oauth-nodejs-client.git"},"contributors":[],"author":{"name":"Ajaykumar Prathap"},"bugs":{"url":"https://github.com/eBay/ebay-oauth-nodejs-client/issues"},"license":"ISC","readme":"# Ebay Oauth Client\n\nThis 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.\n\n[![npm version](https://badge.fury.io/js/ebay-oauth-nodejs-client.svg)](https://badge.fury.io/js/ebay-oauth-nodejs-client)\n[![Build Status](https://travis-ci.com/eBay/ebay-oauth-nodejs-client.svg?branch=master)](https://travis-ci.com/github/eBay/ebay-oauth-nodejs-client)\n\n\n## Table of Contents\n\n* [What is OAuth 2.0](#what-is-oauth)\n* [Installation](#installation)\n* [Library Setup and getting started](#library-setup-and-getting-started)\n* [Configure credentials](#configure-credentials)\n* [Types of Tokens](#types-of-tokens)\n   * [Application Token](#application-token)\n   * [User Token](#user-token) \n* [Supported Grant Types for OAuth](#supported-grant-types-for-oauth)\n    * [Grant Type: Client Credentials](#client-credentials)\n    * [Grant Type: Authorization Code](#authorization-code)\n    * [Grant Type: Refresh Token](#refresh-token)\n* [References](#references)\n* [License](#license)\n\n## What is OAuth\nOAuth 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. \nSee: https://developer.ebay.com/api-docs/static/oauth-tokens.html\n\n## Installation\n\nUsing npm:\n```shell\nnpm install ebay-oauth-nodejs-client\n```\n\nUsing yarn:\n```shell\nyarn add ebay-oauth-nodejs-client\n```\n\n## Usage\n\n##### EbayAuthToken(config)\nCreate a new instance of `EbayAuthToken` with a relevant config.\n```js\nconst EbayAuthToken = require('ebay-oauth-nodejs-client');\n\nconst ebayAuthToken = new EbayAuthToken({\n    clientId: '<your_client_id>',\n    clientSecret: '<your_client_secret>',\n    redirectUri: '<redirect uri>'\n});\n```\n\n##### ebayAuthToken.getApplicationToken(environment)\nGenerate client credential token.\n```js\n(async () => {\n    const token = await ebayAuthToken.getApplicationToken('PRODUCTION');\n    console.log(token);\n})();\n```\n\n##### ebayAuthToken.generateUserAuthorizationUrl(environment, scopes[, options])\nGenerate user consent authorization url.\n```js\n(() => {\n    const authUrl = ebayAuthToken.generateUserAuthorizationUrl('PRODUCTION', scopes);\n    console.log(authUrl);\n})();\n```\n\nYou can also provide optional values:\\\n**state:** An opaque value used by the client to maintain state between the request and callback.\\\n**prompt:** Force a user to log in when you redirect them to the Grant Application Access page, even if they already have an existing user session.\n\nThe method call above could also be done as\n```js\n(() => {\n    const options = { state: 'custom-state-value', prompt: 'login' };\n    const authUrl = ebayAuthToken.generateUserAuthorizationUrl('PRODUCTION', scopes, options);\n    console.log(authUrl);\n})();\n```\n\n##### ebayAuthToken.exchangeCodeForAccessToken(environment, code)\nGetting a User access token.\n```js\n(async () => {\n    const accessToken = await ebayAuthToken.exchangeCodeForAccessToken('PRODUCTION', code);\n    console.log(accessToken);\n})();\n```\n\n##### ebayAuthToken.getAccessToken(environment, refreshToken, scopes)\nUsing a refresh token to update a User access token (Updating the expired access token).\n```js\n(async () => {\n    const accessToken = await ebayAuthToken.getAccessToken('PRODUCTION', refreshToken, scopes);\n    console.log(accessToken);\n})();\n```\n\n## Library Setup and getting started\n\n1. Invoke the oauth ebay library as given below\n```javascript\nconst EbayAuthToken = require('ebay-oauth-nodejs-client');\nconst ebayAuthToken = new EbayAuthToken({\n    filePath: 'demo/eBayJson.json' // input file path.\n})\n```\nOR\n```javascript\nconst ebayAuthToken = new EbayAuthToken({\n    clientId: '<your_client_id>',\n    clientSecret: '<your_client_secret>',\n    redirectUri: '<redirect_uri_name>'\n});\n```\n2. If you want to get your application credentials such as AppId, DevId, and CertId. Refer to [Creating eBay Developer Account](https://developer.ebay.com/api-docs/static/creating-edp-account.html) for details on how to get these credentials.\n3. You can refer to example.js for an example of how to use credentials.\n4. For Authorization code grant\n    1. Get User consent url using ```ebayAuthToken.generateUserAuthorizationUrl()```\n    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);```\n    3. Pass the authorization code retrieved in the above step to exchangeCodeForAccessToken method using ```ebayAuthToken.exchangeCodeForAccessToken(environment, code)```\n\n## Configure credentials\nCreate 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.\n\n```json\n{\n    \"SANDBOX\": {\n        \"clientId\": \"---Client Id---\",\n        \"clientSecret\": \"--- client secret---\",\n        \"devid\": \"-- dev id ---\",\n        \"redirectUri\": \"-- redirect uri ---\",\n        \"baseUrl\": \"api.sandbox.ebay.com\" //don't change these values\n    },\n    \"PRODUCTION\": {\n        \"clientId\": \"---Client Id---\",\n        \"clientSecret\": \"--- client secret---\",\n        \"devid\": \"-- dev id ---\",\n        \"redirectUri\": \"-- redirect uri ---\",\n        \"baseUrl\": \"api.ebay.com\" //don't change these values\n    }\n}\n```\n\n## Types of Tokens\nThere are mainly two types of tokens in usage.\n\n### Application Token\nAn 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.,\n### User Token\nA 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.\n\n## Supported Grant Types for OAuth\nAll of the regular OAuth 2.0 specifications such as client_credentials, authorization_code, and refresh_token are supported. [Refer to eBay Developer Portal](https://developer.ebay.com/api-docs/static/oauth-tokens.html)\n\n### Client Credentials\nThis grant type can be performed by simply using ```ebayAuthToken.getApplicationToken()```. Read more about this grant type at [oauth-client-credentials-grant](https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html).\n\n### Authorization Code\n\nThis 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.\n\nRead more about this grant type at [oauth-authorization-code-grant](https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html).\n\n### Refresh Token\n\nThis 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](https://developer.ebay.com/api-docs/static/oauth-auth-code-grant-request.html)\n\n## Questions/problems?\nyou've found an bug/issue, please file it on [GitHub](https://github.com/eBay/ebay-oauth-nodejs-client/issues).\n\n## References\n\n1. https://developer.ebay.com/api-docs/static/oauth-tokens.html\n\n2. https://developer.ebay.com/api-docs/static/oauth-quick-ref-user-tokens.html\n\n3. https://developer.ebay.com/api-docs/static/oauth-gen-app-token.html\n\n4. https://developer.ebay.com/my/keys\n\n## License \nCopyright (c) 2019 eBay Inc.\n\nUse 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.\n\n## Useful links\n\n* Getting Client Id and Client Secret: https://developer.ebay.com/api-docs/static/oauth-credentials.html\n* Getting your redirect_uri value: https://developer.ebay.com/api-docs/static/oauth-redirect-uri.html\n* Specifying right scopes: https://developer.ebay.com/api-docs/static/oauth-scopes.html\n","readmeFilename":"README.md"}