GithubHelp home page GithubHelp logo

quanglatte / jetsy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from notronix/jetsy

0.0 0.0 0.0 204 KB

A Java implementation of a Java version of the Etsy API

License: Apache License 2.0

Java 100.00%

jetsy's Introduction

JEtsy

A Java implementation of a Java version of the Etsy API

About

JEtsy (Java Etsy API) is 2 things:

  1. An API. JEtsy provides a Java version of the Etsy API. Etsy's REST API is fully described using java interfaces. This allows anyone to build their own implementation of that API and makes adapting or extending the implementation much easier to achieve.
  2. An Implementation. JEtsy provides a full implementation of the API mentioned above. This makes JEtsy usable right out of the gate. There's nothing to change, unless you need a specific feature or would rather use different underlying implementations (ex. a different Http transport).

Installation

Version 1.0.0012 of JEtsy is available from the Maven Central Repository here

<dependency>
    <groupId>com.notronix</groupId>
    <artifactId>JEtsy</artifactId>
    <version>1.0.0012</version>
</dependency>

Usage

JEtsy is intended to be used as a way to allow any Java developer to quickly get their own application (known as the "Client") off the ground and running. As a result, the first step required is to register your own application with Etsy. This registration process will provide you with both a "key string" and a "shared secret" (known as the "Client Credentials"). The client credentials can then be used with JEtsy to obtain access credentials and to authorize the use of your application with an existing Etsy account. The following steps illustrate how to get started.

  1. Register your Java application with Etsy here.

  2. Record the "key string" and "shared secret" provided by completing step 1 above.

  3. Create an instance of EtsyDataService using the information from step 2 above.

    EtsyDataService etsyDataService = new EtsyDataService("YourKeyString", "YourSharedSecret");

  4. Use the etsyDataService to make API calls that do not require OAuth authentication.

    List<EtsyApiMethod> methods = etsyDataService.getMethodTable();

  5. To make API calls that require OAuth authentication, obtain your temporary OAuth credentials. These credentials will provide you with a login URL that can be used in any browser to grant your application (client) access to an existing Etsy account.

    Note that the example below uses an out of band (oob) oauth process. As a result, Etsy will display the verifier required in the next step. If you provide a callback URL of your own, Etsy will redirect to your provided URL and specify your verifier token.

    Set<String> scopes = Arrays.stream(EtsyScope.values()).map(Enum::name).collect(toSet());
    Credentials temporaryCreds = etsyDataService.getTemporaryCredentials(scopes, "oob");
    String loginUrl = temporaryCreds.getLoginUrl();
    
    
    
  6. Visit Etsy via the login URL obtained in step 4 above. Etsy will require you to login to an existing Etsy account. After a successful login, Etsy will ask you to grant your application (client) access to your account. If you specified an OOB callback then record the verifier code presented to you. If you specified your own callback URL, then Etsy will redirect to your URL and provide the verifier code as a query parameter.

  7. Use the EtsyDataService object and your verifier code to obtain access credentials. Access credentials will be required whenever the Etsy API indicates that OAuth is required. Details of the API methods are available here

    String verifier = "VerificationCodeProvidedByEtsy"; // replace this with your verification code
    Credentials accessCreds = etsyDataService.getAccessCredentials(temporaryCreds, verifier);
    
    
    
  8. Use the EtsyDataService and your credentials to make API calls to Etsy. The example below shows an API call to get the Etsy user associated with the account that was verified in step 5.

    List<String> userIdsOrNames = Collections.singletonList(EtsyAPI.__SELF__);
    List<EtsyUser> users = etsyDataService.getUser(accessCreds, userIdsOrNames, UserAssociations.values());
    EtsyUser authorizedEtsyAccountUser = users.get(0);
    
    
    

Contribution

  1. Found an issue? Add the details here
  2. Need a missing Etsy API method call added to this library? Add the details here
  3. Want code changed? Fork the repository and make a pull request.

jetsy's People

Contributors

cmunden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.