Coder Social home page Coder Social logo

auth-swift's Introduction

Ricoh Auth Client for Swift

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

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

Requirements

  • Swift 2.2+
  • Xcode 7.3.1+

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 two different methods to install Ricoh Auth Client for Swift in your application.
See Auth Sample to try out a sample of Ricoh Auth Client for Swift.

CocoaPods

  • If it is your first time to use CocoaPods, run the following commands to set it up.
$ gem install cocoapods
$ pod setup
  • Go to your project directory.
  • Create a Podfile by running pod init ( if you do not have one yet ), and specify RicohAPIAuth as follows:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'YourAppName' do
  pod 'RicohAPIAuth', '~> 1.0.2'
end
  • Run pod install to install RicohAPIAuth.
  • Open your project's workspace.
  • Choose your application scheme and run it to load the RicohAPIAuth module.
  • Install completed! See Sample Flow for a coding example.

Manually

  • Clone Ricoh Auth Client for Swift by running the following commands:
$ git clone https://github.com/ricohapi/auth-swift.git
  • Open the new auth-swift directory, and drag RicohAPIAuth.xcodeproj into the Project Navigator of your application's Xcode project.

    It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Choose RicohAPIAuth scheme at the scheme menu of Xcode and run it.

  • Choose your application scheme and run it to load the RicohAPIAuth module.

  • Install completed! See Sample Flow for a coding example.

Sample Flow

// Import
import RicohAPIAuth

// Set your Ricoh API Client Credentials
var authClient = AuthClient(
    clientId: "<your_client_id>",
    clientSecret: "<your_client_secret>"
)

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

// Open a new session
authClient.session(){result, error in
if !error.isEmpty() {
    print("status code: \(error.statusCode)")
    print("error message: \(error.message)")
} else {
    print("access token : \(result.accessToken)")
}

SDK API Samples

Constructor

var authClient = AuthClient(
    clientId: "<your_client_id>",
    clientSecret: "<your_client_secret>"
)

Set resource owner credentials

authClient.setResourceOwnerCreds(
    userId: "<your_user_id>",
    userPass: "<your_password>"
)

Open a new session

authClient.session(){result, error in
if error.isEmpty() {
    print("access token : \(result.accessToken)")
    // do something
}

Resume a preceding session

// This method resumes a preceding session if it is closed.
authClient.getAccessToken(){result, error in
if error.isEmpty() {
    print("access token : \(result.accessToken)")
    // do something
}

auth-swift'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.