Swiftpack.co - Package - Adaptavant/fullauth-api-ios-client

FullAuthIOSClient

Build Status Version License Platform

Supported Operations

Requirements

  • iOS 10.0+
  • Xcode 11+
  • Swift 4.2+

Latest Version

1.0.1 is the current latest version For change logs refer Releases

Installation

FullAuthIOSClient is available through CocoaPods. To install it, simply add the following line to your Podfile:

CocoaPods

pod "FullAuthIOSClient"

Swift Package Manager

FullAuthIOSClient is available through Swift Package Manager. To install it, simply add the following dependency to your Package.swift

.package(url: "https://github.com/Adaptavant/fullauth-api-ios-client.git", from: "1.0.1")

Requesting Access Token

There are few supported flows in the fullAuth specification to request access token as follows

Create an authService by providing the necessary inputs.

let authService =  FullAuthOAuthService(authDomain: "your auth domain":, clientId: "client-id", clientSecret: "client-secret")

Using Resource Owner Credentials

A Resource Owner’s username and password are submitted as part of the request, and a token is issued upon successful authentication.

do {
    try authService.requestAccessTokenForResourceCredentials("user-email-id", password: "password", scope: ["scope1", "scope2"], accessType: .OFFLINE, handler: { (error, errorResponse, accessToken) -> Void in
    // process full auth response
         })
    } catch let err {
             // handle error 
    }

Using Google Access Token

Request AccessToken by passing valid google access token.

 do {
     try authService.requestAccessTokenForGoogleToken(googleAccessToken: "googleToken", scope: ["scope1", "scope2"], accessType: .OFFLINE, handler: { (error, errorResponse, accessToken) in
                   // process the response
               })
    } catch let err {
             // handle the error 
    }

Using Facebook Access Token

Request AccessToken by passing valid facebook access token.

do {
    try authService.requestAccessTokenForGoogleToken(faceBookAccessToken: "facebookToken", scope: ["scope1", "scope2"], accessType: .OFFLINE, handler: { (error, errorResponse, accessToken) in
                  // process the response
              })
   } catch let err {
            // handle the error 
   }

Fetch access token information

Access token information can be obtained by the following method.

do {
    try authService.getTokenInfo("pass the accessToken") { (err, errResponse, token) in
            // token information is received here
        }
    } catch {
            // handle the error
    }

Refresh Access Token

You can submit a refresh token and receive a new access token if the access token had expired.

 do {
     try authService.refreshAccessToken("your refreshToken", expiryType: OauthExpiryType.LONG) { (error, errorResponse, accessToken) -> Void in
            // Save the access token
    } catch let error {
            // print("error: \(error)")
    }

Revoke Access Token

Revoke a valid AccessToken.

 do {
     try authService.revokeToken(token: "your token", tokenType: RevokeTokenHintType.ACCESS_TOKEN) { (success, err, errResp) in
               // success for revoking the access token
     } catch {
          // print error
     }

Author

karthik-dev Monica Raja

License

FullAuthIOSClient is available under the MIT license. See the LICENSE file for more info.

Github

link
Stars: 1
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.0 - Jun 26, 2019

0.9.6 - Dec 10, 2018

  • Revoke Token and Token Info Api Changes
  • Build with fastlane

0.9.1 - Nov 22, 2018

Fixed Architecture Issue. expires will be in Int64

0.9.0 - Nov 17, 2018

Added the property "expires" in OAuthAccessToken which gives the expiry time of the AccessToken