JDBC Driver for eBay

Build 22.0.8462

Creating a Custom OAuth App

There are two authentication methods available for connecting to eBay:

Using a token generated for accessing only personal data or using tokens that allow other users to access their own data. Both methods require you to join the eBay Developers Program, https://developer.ebay.com/.

Register and Get Your Keyset

After joining the eBay Developers Program, you can obtain the following values from the Application Keysets page (Developer Account Dashboard -> Application Keysets).

  1. OAuthClientId (App ID)
  2. DevID
  3. OAuthClientSecret (Cert ID)

Using a User Token

If you are working with your own account, follow the steps below to generate a token from eBay's user interface:

  1. Go to your Developer Account Dashboard and open the User Access Tokens page.
  2. Select the environment for your app.
    • Select 'Production' if you are searching for real items or listing real items to the live eBay site.
    • Select 'Sandbox' if you are creating test listings in the sandbox.
  3. Underneath 'Get a User Token Here', select the authentication method to use when generating a token. OAuth tokens are valid for all Ebay APIs (RESTful APIs and Traditional APIs), while Auth'N'Auth tokens are only valid for the Traditional APIs.

  4. Click 'Sign in to Sandbox' or 'Sign in to Production' depending on the environment, and log in with credentials for either your sandbox or production eBay account.

Note: To enable OAuth authentication, you should check the 'OAuth Enabled' checkbox under 'Your eBay Sign-in Settings' for the RuName (eBay Redirect URL name) that you will be using to sign-in. If it is not enabled, then only the Auth'N'Auth authentication method will be supported. See the 'Set Up an OAuth App' section for more information.

You can then set the following connection properties and connect:

  • AuthScheme: Set this to "OAuth" if you want to use OAuth as the authentication method. If AuthScheme is set to "AuthNAuth" or if it is not specified, Auth'n'Auth will be used to authenticate.
  • InitiateOAuth: Set this to OFF if you are using OAuth authentication and a token generated from eBay's user interface.
  • OAuthAccessToken: Set this to the User Token you generated from your developer account dashboard.

    Note that Auth'N'Auth tokens expire after 18 months, while OAuth tokens expire after 2 hours. If you want the driver to automatically refresh the OAuth access token, see the below sections on Authenticating from a Desktop or Web application.

  • SiteID: Set this to the eBay site ID. By default this is "0" (the U.S. site).
  • UseSandbox: Set this to "true" if you generated a token for the sandbox environment.

Getting Tokens for Applications with Multiple Users

eBay implements the OAuth authentication standard, which you can use to access your own data or allow other users to access their own data.

OAuth requires the authenticating user to interact with eBay using the browser. The driver facilitates this in various ways as described in the following sections.

Set Up an OAuth App

Follow the steps below to configure the user consent flow:

  1. Go to your Developer Account Dashboard and open the User Access Tokens page.
  2. Select the environment for your app.
    • Select 'Production' if you are searching for real items or listing real items to the live eBay site.
    • Select 'Sandbox' if you are creating test listings in the sandbox.
  3. Underneath 'Your eBay Sign-in Settings' in the 'Get a Token from eBay via Your Application' section, add a new RuName (eBay Redirect URL) by clicking on 'Add eBay Redirect URL' or expand the tab for the RuName that you will be using to authenticate.
  4. Check the 'OAuth Enabled' checkbox for your RuName. If it is not enabled, then only the Auth'N'Auth authentication method will be supported.
  5. Set 'Your auth accepted URL' to "https://oauth.cdata.com/oauth/" since the eBay requires a secure Redirect URI (https) and does not accept a localhost URI.
  6. Click 'Save' to save your changes.
  7. Select 'OAuth', then click 'Test Sign-In' to verify that you can sign-in with your RuName.

Authenticate to eBay from a Desktop Application

After setting the following connection properties, you are ready to connect:

  • AuthScheme: Set this to "OAuth" if you want to use OAuth as an authentication method. If it is set to "AuthNAuth" or if it is not specified, Auth'n'Auth will be used to authenticate.
  • DevID: Set this to the Developer ID from your keyset.
  • OAuthClientId: Set this to the App ID (Client ID) from your keyset.
  • OAuthClientSecret: Set this to the Cert ID (Client Secret) from your keyset.
  • RuName: Set this to the RuName (eBay Redirect URL name) that you will use to sign-in.
  • SiteID: Set this to the eBay site ID. By default this is 0 (the U.S. site).
  • CallbackURL: Set this to "http://localhost:33333" or another port of your choice.
  • InitiateOAuth: Set this to GETANDREFRESH.
  • UseSandbox: Set this to "true" if you are using a sandbox account.
When you connect, the driver opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the authentication process:
  1. Exchanges the OAuth verifier code for an OAuth access and refresh token.
  2. Saves the OAuth tokens in OAuthSettingsLocation to be persisted across connections.

Authenticate to eBay from a Web Application

When connecting via a Web application, or if the driver is not authorized to open a browser window, you need to exchange a "Session Id" (if you are using Auth'n'Auth as an authentication method) or a verifier code (if you are using OAuth) for the OAuthAccessToken. Set the following connection properties:

  • AuthScheme: Set this to "OAuth" if you want to use OAuth as an authentication method. If it is set to "AuthNAuth" or if it is not specified, Auth'n'Auth will be used to authenticate.
  • DevID: Set this to the Developer ID in your keyset.
  • OAuthClientId: Set this to the App ID (Client ID) in your keyset.
  • OAuthClientSecret: Set this to the Cert ID (Client Secret) in your keyset.
  • RuName: Set this to the RuName (eBay Redirect URL name) that you will use to sign-in.
  • SiteID: Set this to the eBay site ID. By default this is 0, (U.S.)
  • CallbackURL: Set this to "http://localhost:33333" or another port of your choice or your preferred Callback URL.
  • InitiateOAuth: Set this to OFF if using OAuth.
  • UseSandbox: Set this to true if you are using a sandbox account.
After setting the above properties, to obtain an OAuthAccessToken follow the below steps:
  1. Call GetOAuthAuthorizationURL. The stored procedure returns the URL to the OAuth or Auth'N'Auth authorization endpoint.
  2. Login and authorize the application. You are redirected back to the callback URL.
  3. Call GetOAuthAccessToken. Set the AuthMode input parameter to "WEB". If you are using OAuth to authenticate, Set the Verifier input parameter to the value of the 'code' query string returned from authorizing your application. Otherwise, if you are using Auth'N'Auth, set the SessionId input parameter to the value of the 'sessionid' in the query string of the authorization URL from the first step or from the Callback URL.
To make requests to eBay, set the OAuthAccessToken connection property, in addition to the preceding connection properties, to the value of the 'OAuthAccessToken' returned from the above call.

Note that Auth'N'Auth tokens expire after 18 months. OAuth tokens expire after 2 hours.

If using OAuth, you can optionally set the OAuthRefreshToken connection property to the value of the 'OAuthRefreshToken' returned from the above call and set InitiateOAuth to REFRESH to automatically refresh the access token when it expires. You can also save the returned value for the 'OAuthRefreshToken' and manually retrieve new tokens by calling RefreshOAuthAccessToken.

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462