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 adeviceUniqueId
once for eachserviceName
and device, storedeviceUniqueId
in keychain. If there is adeviceUniqueId
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 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
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.
-
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 thatAuthorizationCodeGrant
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 thatAuthorizationCodeGrant
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.
-
Authorize with
RefreshToken
grant type.Declaration
Swift
func authorize(grant: RefreshTokenGrant, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?)
Parameters
grant
The
grant
information thatRefreshTokenGrant
completion
The closure to receive result for authorization.
-
Authorize with
ClientCredentials
grant type.Declaration
Swift
func authorize(grant: ClientCredentialsGrant, completion: ((Result<AuthorizationInfo, NuguLoginKitError>) -> Void)?)
Parameters
grant
The
grant
information thatClientCredentialsGrant
completion
The 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
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
.