NuguOAuthClient
public class NuguOAuthClient
<#Description#>
-
The
deviceUniqueIdis unique identifier each device.Declaration
Swift
private(set) public var deviceUniqueId: String { get } -
The initializer for
NuguOAuthClient. Create adeviceUniqueIdonce for eachserviceNameand device, storedeviceUniqueIdin keychain. If there is adeviceUniqueIdstored in the keychain, it is used.Declaration
Swift
public convenience init(serviceName: String) throwsParameters
serviceNameThe
serviceNameis unique identifier each service (eg. bundle identifier). -
The initializer for
NuguOAuthClient. Should be useinit(serviceName: String)instead ofinit(deviceUniqueId: String). Only useinit(deviceUniqueId: String)when it must explicitly useddeviceUniqueId. It cannot store and validatedeviceUniqueId.Declaration
Swift
public init(deviceUniqueId: String)Parameters
deviceUniqueIdThe
deviceUniqueIdis unique identifier each device. -
Use to change the
deviceUniqueId.Declaration
Swift
public func update(deviceUniqueId: String)Parameters
deviceUniqueIdThe
deviceUniqueIdis unique identifier each device.
-
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
urlThe URL as passed to
UIApplicationDelegate.application(app:url:options:). -
Authorize with
AuthorizationCodegrant type.Declaration
Swift
func authorize( grant: AuthorizationCodeGrant, parentViewController: UIViewController, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)? )Parameters
grantThe
grantinformation thatAuthorizationCodeGrantparentViewControllerThe
parentViewControllerwill present a safariViewController.completionThe closure to receive result for authorization.
-
Shows web-page where TID information can be modified with
AuthorizationCodegrant type.Declaration
Swift
func showTidInfo( grant: AuthorizationCodeGrant, token: String, parentViewController: UIViewController, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)? )Parameters
grantThe
grantinformation thatAuthorizationCodeGranttokenThe
tokenis access-token currently being used.parentViewControllerThe
parentViewControllerwill present a safariViewController.completionThe 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
clientIdThe
clientIdfor OAuth authentication.clientSecretThe
clientSecretfor OAuth authentication.tokenThe
tokenis access-token currently being used.completionThe closure to receive result for getting NUGU member information.
-
Authorize with
RefreshTokengrant type.Declaration
Swift
func authorize(grant: RefreshTokenGrant, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?)Parameters
grantThe
grantinformation thatRefreshTokenGrantcompletionThe closure to receive result for authorization.
-
Authorize with
ClientCredentialsgrant type.Declaration
Swift
func authorize(grant: ClientCredentialsGrant, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?)Parameters
grantThe
grantinformation thatClientCredentialsGrantcompletionThe closure to receive result for authorization.
-
Revoke completly with NUGU
Declaration
Swift
func revoke(clientId: String, clientSecret: String, token: String, completion: ((EndedUp<NuguLoginKitError>) -> Void)?)Parameters
clientIdThe
clientIdfor OAuth authentication.clientSecretThe
clientSecretfor OAuth authentication.tokenThe
tokenis access-token currently being used.completionThe closure to receive result for
revoke.
View on GitHub
NuguOAuthClient Class Reference