eBay OAuth client library is a simple and easy-to-use library for integrating with eBay OAuth and designed to be used for OAuth 2.0 specification supported by eBay. There are multiple standard clients that can be used with eBay OAuth, such as Spring OAuth client. However, this library in addition to functioning as a simple eBay OAuth client, helps with additional features such as cached App tokens. There are also future enhancements planned to add id_token support, 'login with eBay' support etc.,
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 is available at developer.ebay.com.
This is created as a Maven based Java project and can be used as a dependency in a Java based application or other JVM based languages such as Groovy, Scala etc.,
Current Version : 1.1.0 Add following to <dependencies/> section of your pom.xml as given below
<dependency>
<groupId>com.ebay.auth</groupId>
<artifactId>ebay-oauth-java-client</artifactId>
<version>1.1.0</version>
</dependency>
All interactions with this library can be performed using OAuth2Api oauth2Api = new OAuth2Api();
-
Ensure you have a config file in your source code of type YAML. Refer to ebay-config-sample.yaml.
-
This file would hold all your application credentials such as AppId, DevId, and CertId. Refer to Creating eBay Developer Account for details on how to get these credentials.
-
Once the file is created, call
CredentialUtil.load(new FileInputStream(<your-config-location>));
to load the credentials. -
It is recommended to load the credentials during startup time (initialization) to prevent runtime delays.
-
Once the credentials are loaded, call any operation on
OAuth2Api
There are mainly two types of tokens in usage.
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.,
All of the regular OAuth 2.0 specifications such as client_credentials
, authorization_code
, and refresh_token
are all supported. Refer to eBay Developer Portal
This grant type can be performed by simply using OAuth2Api.getApplicationToken()
. Read more about this grant type at oauth-client-credentials-grant
This grant type can be performed by a two step process. Call OAuth2Api.generateUserAuthorizationUrl()
to get the Authorization URL to redirect the user to. Once the user authenticates and approves the consent, the callback need to be captured by the redirect URL setup by the app and then call OAuth2Api.exchangeCodeForAccessToken()
to get the refresh and access tokens.
Read more about this grant type at oauth-authorization-code-grant and Quick Reference
This grant type can be performed by simply using OAuth2Api.getAccessToken()
. 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
Contributions in terms of patches, features, or comments are always welcome. Refer to CONTRIBUTING for guidelines. Submit Github issues for any feature enhancements, bugs, or documentation problems as well as questions and comments.
Copyright (c) 2018 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.