Using OAuth Authentication
OAuth requires the authenticating user to interact with eBay using the browser. The provider facilitates this in various ways as described below.
Custom Credentials
You will need to register an app to obtain the OAuthClientId and OAuthClientSecret.
Web Applications
You need to create an OAuth app to use in the web flow.
Desktop Applications
You need to create an OAuth app.
Headless Machines
In the headless OAuth flow, users need to authenticate via a browser on another machine. You will need to create a custom OAuth app.
Creating a Custom OAuth App
See Creating a Custom OAuth App for a procedure.
Custom Credentials
Desktop Authentication with your OAuth App
Follow the steps below to authenticate with the credentials for a custom OAuth app. See Creating a Custom OAuth App.Get an OAuth Access Token
After setting the following, you are ready to connect:
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- CallbackURL: Set this to the Redirect URL in your app settings.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken. .
- Extracts the access token from the callback URL and authenticates requests.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Web Authentication with your OAuth App
When connecting via a Web application, you need to register a custom OAuth app with eBay. See Creating a Custom OAuth App. You can then use the provider to get and manage the OAuth token values.
Get an OAuth Access Token
Set the following connection properties to obtain the OAuthAccessToken:
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
You can then call stored procedures to complete the OAuth exchange:
-
Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the Redirect URI you specified in your app settings. If necessary, set the Permissions parameter to request custom permissions.
The stored procedure returns the URL to the OAuth endpoint.
- Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
- Call the GetOAuthAccessToken stored procedure. Set the AuthMode input to WEB. Set the Verifier input to the "code" parameter in the query string of the callback URL. If necessary, set the Permissions parameter to request custom permissions.
To connect to data, set the OAuthAccessToken connection property to the access token returned by the stored procedure. When the access token expires after ExpiresIn seconds, call GetOAuthAccessToken again to obtain a new access token.
Headless Machines
Using OAuth on a Headless Machine
To create eBay data sources on headless servers or other machines on which the provider cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.
- Instead of installing the provider on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the provider on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
- You can then configure the provider to automatically refresh the access token from the headless machine.
Using the Credentials for a Custom OAuth App
Create a Custom OAuth App
See Creating a Custom OAuth App for a procedure. You can then follow the procedures below to authenticate and connect to data.
Obtain a Verifier Code
Set the following properties on the headless machine:
- InitiateOAuth: Set this to OFF.
- OAuthClientId: Set this to the App Id in your app settings.
- OAuthClientSecret: Set this to the App Secret in your app settings.
You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.
- Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
- Open the returned URL in a browser. Log in and grant permissions to the provider. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. You will set this in the OAuthVerifier connection property.
On the headless machine, set the following connection properties to obtain the OAuth authentication values:
- OAuthVerifier: Set this to the verifier code.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
- InitiateOAuth: Set this to REFRESH.
Connect to Data
After the OAuth settings file is generated, set the following properties to connect to data:
- OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- InitiateOAuth: Set this to REFRESH.
Transfer OAuth Settings
Follow the steps below to install the provider on another machine, authenticate, and then transfer the resulting OAuth values.
On a second machine, install the provider and connect with the following properties set:
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- CallbackURL: Set this to the Callback URL in your app settings.
Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: Set this to REFRESH.
- OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
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.
Register and Get Your Keys
After joining the eBay Developers Program, you can obtain the following values from the Application Keys page (My Account -> Application access keys).
- OAuthClientId (App ID)
- DevID
- OAuthClientSecret (Cert ID)
Using a Personal Token
If you're working with your own account, follow the steps below to generate a token:
- Go to your Developer Account Dashboard and open the Application Keys page.
-
In the App ID (Client ID) row for the key set you want to use, click User Tokens.
Use production keys if you're searching for real items or listing real items to the live eBay site. Use sandbox keys if you're creating test listings in the sandbox.
- Click Get a User Token Here and log in with credentials for either your sandbox or production eBay account.
- DevID: Set this to the Developer ID from your key set.
- OAuthClientId: Set this to the App ID (Client ID) from your key set.
- OAuthClientSecret: Set this to the Cert ID (Client Secret) from your key set.
- SiteID: Set this to the eBay site ID. By default this is 0 (the U.S. site).
- OAuthAccessToken: Set this to the personal token you generated from your developer account dashboard.
- UseSandbox: Set this to true if you are using a sandbox account.
- UseOAuth: Set this to true if you want to use OAuth 2.0 as an authentication method. If it is set to "false" or if it is not specified, Auth and Auth will be used to authenticate.
Getting Tokens for Applications with Multiple Users
eBay implements the OAuth authentication standard, which you can use to allow other users to access their own data.
OAuth requires the authenticating user to interact with eBay using the browser. The provider 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:
- Go to your Developer Account Dashboard and open the Application Keys page.
- In the App ID (Client ID) row for your app, click User Tokens.
- Click Get a Token from eBay via Your Application, then click Add eBay Redirect URL, and set the RuName to the resulting value.
Authenticate to eBay from a Desktop Application
After setting the following connection properties, you are ready to connect:
- DevID: Set this to the Developer ID from your key set.
- OAuthClientId: Set this to the App ID (Client ID) from your key set.
- OAuthClientSecret: Set this to the Cert ID (Client Secret) from your key set.
- RuName: Set this to the Redirect URL name on the Token from eBay via your Application section of the User Tokens page.
- 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.
- UseOAuth: Set this to true if you want to use OAuth 2.0 as an authentication method. If it is set to "false" or if it is not specified, Auth and Auth will be used to authenticate.
- Extracts the token and authenticates requests.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Authenticate to eBay from a Web Application
To obtain the access token, set the following connection properties:
- DevID: Set this to the Developer ID in your key set.
- OAuthClientId: Set this to the App ID (Client ID) in your key set.
- OAuthClientSecret: Set this to the Cert ID (Client Secret) in your key set.
- SiteID: Set this to the eBay site ID. By default this is 0, (U.S.)
- RuName: Set this to the Redirect URL name on the Token from eBay via your Application section of the User Tokens page.
- UseSandbox: Set this to true if you are using a sandbox account.
- UseOAuth: Set this to true if you want to use OAuth 2.0 as an authentication method. If it is set to "false" or if it is not specified, Auth and Auth will be used to authenticate.
When connecting via a Web application, or if the provider is not authorized to open a browser window, you need to exchange a session Id (if you are using Auth and Auth as an authentication method) or a verifier code (if you are using OAuth 2.0) for the OAuthAccessToken:
- Set the UseSandbox connection property to true if you are using a sandbox account.
- Set the UseOAuth connection property to true if you want to use OAuth instead of Auth and Auth to authenticate.
- Call GetOAuthAuthorizationURL. The stored procedure returns the URL to the OAuth endpoint.
- Log in and authorize the application. You are redirected back to the callback URL.
- Call GetOAuthAccessToken. Set the AuthMode paramater to "WEB". If you are using OAuth to authenticate, set the Verifier value to the value of the code returned from the previous step. Otherwise, if you are using Auth and Auth, set the SessionId parameter to the SessionId parameter returned in the query string of the callback URL from the previous step.
Customizing the SSL Configuration
By default, the provider attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store. To specify another certificate, see the SSLServerCert property for the available formats to do so.
Connecting Through a Firewall or Proxy
HTTP Proxies
To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.
In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.
Other Proxies
Set the following properties:
- To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
- To tunnel the connection, set FirewallType to TUNNEL.
- To authenticate, specify FirewallUser and FirewallPassword.
- To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.
Troubleshooting the Connection
To show provider activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the provider's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.
- The certificate presented by the server cannot be validated: This error indicates that the provider cannot validate the server's certificate through the chain of trust. If you are using a self-signed certificate, there is only one certificate in the chain.
To resolve this error, you must verify yourself that the certificate can be trusted and specify to the provider that you trust the certificate. One way you can specify that you trust a certificate is to add the certificate to the trusted system store; another is to set SSLServerCert.