NuguOAuthClient

public class NuguOAuthClient

<#Description#>

  • The deviceUniqueId is unique identifier each device.

    Declaration

    Swift

    private(set) public var deviceUniqueId: String { get }
  • The initializer for NuguOAuthClient. Create a deviceUniqueId once for each serviceName and device, store deviceUniqueId in keychain. If there is a deviceUniqueId stored in the keychain, it is used.

    Declaration

    Swift

    public convenience init(serviceName: String) throws

    Parameters

    serviceName

    The serviceName is unique identifier each service (eg. bundle identifier).

  • The initializer for NuguOAuthClient. Should be use init(serviceName: String) instead of init(deviceUniqueId: String). Only use init(deviceUniqueId: String) when it must explicitly used deviceUniqueId. It cannot store and validate deviceUniqueId.

    Declaration

    Swift

    public init(deviceUniqueId: String)

    Parameters

    deviceUniqueId

    The deviceUniqueId is unique identifier each device.

  • Use to change the deviceUniqueId.

    Declaration

    Swift

    public func update(deviceUniqueId: String)

    Parameters

    deviceUniqueId

    The deviceUniqueId is unique identifier each device.

AuthorizationCodeGrant

  • Call this method from the UIApplicationDelegate.application(app:url:options:) method of the AppDelegate for your app.

    It should be implemeted to receive authorization-code by SFSafariViewController.

    Declaration

    Swift

    class func handle(url: URL)

    Parameters

    url

    The URL as passed to UIApplicationDelegate.application(app:url:options:).

  • Authorize with AuthorizationCode grant type.

    Declaration

    Swift

    func authorize(
        grant: AuthorizationCodeGrant,
        parentViewController: UIViewController,
        completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?
    )

    Parameters

    grant

    The grant information that AuthorizationCodeGrant

    parentViewController

    The parentViewController will present a safariViewController.

    completion

    The closure to receive result for authorization.

  • Shows web-page where TID information can be modified with AuthorizationCode grant type.

    Declaration

    Swift

    func showTidInfo(
        grant: AuthorizationCodeGrant,
        token: String,
        parentViewController: UIViewController,
        completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?
    )

    Parameters

    grant

    The grant information that AuthorizationCodeGrant

    token

    The token is access-token currently being used.

    parentViewController

    The parentViewController will present a safariViewController.

    completion

    The closure to receive result for authorization.

  • Get some NUGU member information.

    Declaration

    Swift

    func getUserInfo(clientId: String, clientSecret: String, token: String, completion: ((Result<NuguUserInfo, NuguLoginKitError>) -> Void)?)

    Parameters

    clientId

    The clientId for OAuth authentication.

    clientSecret

    The clientSecret for OAuth authentication.

    token

    The token is access-token currently being used.

    completion

    The closure to receive result for getting NUGU member information.

RefreshTokenGrant

ClientCredentialsGrant

Util API

  • Revoke completly with NUGU

    Declaration

    Swift

    func revoke(clientId: String, clientSecret: String, token: String, completion: ((EndedUp<NuguLoginKitError>) -> Void)?)

    Parameters

    clientId

    The clientId for OAuth authentication.

    clientSecret

    The clientSecret for OAuth authentication.

    token

    The token is access-token currently being used.

    completion

    The closure to receive result for revoke.