Giter Site home page Giter Site logo

auth-java's Introduction

Ricoh Auth Client for Java

This open-source library allows you to integrate Ricoh API's Authorization and Discovery Service into your Java app.

Learn more at http://docs.ricohapi.com/

Requirements

  • java 1.8+

You'll also need

  • Ricoh API Client Credentials (client_id & client_secret)
  • Ricoh ID (user_id & password)

If you don't have them, please register yourself and your client from THETA Developers Website.

Installation

This section shows you to install Ricoh Auth Client for Java in your application.
See Auth Sample to try out a sample of Ricoh Auth Client for Java.

  • Download: ricoh-api-auth.jar
  • Drag ricoh-api-auth.jar into a directory (ex. libs) of your application.
  • Edit your application's build.gradle as follows.
dependencies {
    compile files('libs/ricoh-api-auth.jar')
}
  • Click the Sync Project with Gradle Files icon to clean and build your application.
  • Install completed! See Sample Flow for a coding example.

Sample Flow

// Import
import com.ricohapi.auth.AuthClient;
import com.ricohapi.auth.CompletionHandler;
import com.ricohapi.auth.Scope;
import com.ricohapi.auth.entity.AuthResult;

// Set your Ricoh API Client Credentials
AuthClient authClient = new AuthClient("<your_client_id>", "<your_client_secret>");

// Set your Ricoh ID
authClient.setResourceOwnerCreds("<your_user_id>", "<your_password>");

// Open a new session
authClient.session(Scope.MSTORAGE, new CompletionHandler<AuthResult>(){
    @Override
    public void onCompleted(AuthResult result) {
        String accessToken = result.getAccessToken();
        // do something
    }

    @Override
    public void onThrowable(Throwable t) {
        // Something wrong happened.
    }
});

SDK API Samples

Constructor

AuthClient authClient = new AuthClient("<your_client_id>", "<your_client_secret>");

Set resource owner credentials

authClient.setResourceOwnerCreds("<your_user_id>", "<your_password>");

Open a new session

authClient.session(Scope.MSTORAGE, new CompletionHandler<AuthResult>(){
    @Override
    public void onCompleted(AuthResult result) {
        String accessToken = result.getAccessToken();
        // do something
    }

    @Override
    public void onThrowable(Throwable t) {
        // Something wrong happened.
    }
});

Resume a preceding session

authClient.getAccessToken(new CompletionHandler<AuthResult>(){
    @Override
    public void onCompleted(AuthResult result) {
        String accessToken = result.getAccessToken();
        // do something
    }

    @Override
    public void onThrowable(Throwable t) {
        // Something wrong happened.
    }
});

auth-java's People

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.