-
-
-

UsergridAuth

-
-
-
public class UsergridAuth : NSObject, NSCoding
- -
-
-

The UsergridAuth class functions to create and store authentication information used by Usergrid.

- -

The UsergridAuth sub classes, UsergridAppAuth and UsergridUserAuth, provide different ways for authentication to be used in creating requests for access tokens through the SDK.

- -
-
-
- -
    -
  • -
    - - - - accessToken - -
    -
    -
    -
    -
    -
    -

    The access token, if this UsergridAuth was authorized successfully.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var accessToken : String?
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - expiry - -
    -
    -
    -
    -
    -
    -

    The expires at date, if this UsergridAuth was authorized successfully and their was a expires in time stamp within the token response.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var expiry : NSDate?
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - hasToken - -
    -
    -
    -
    -
    -
    -

    Determines if an access token exists.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var hasToken: Bool { return self.accessToken != nil }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - isValid - -
    -
    -
    -
    -
    -
    -

    Determines if an access token exists and if the token is not expired.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var isValid : Bool { return self.hasToken && !self.isExpired }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - isExpired - -
    -
    -
    -
    -
    -
    -

    Determines if the access token, if one exists, is expired.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var isExpired: Bool
    - -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Initializer for a base UsergridAuth object that just contains an accessToken and an optional expiry date.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(accessToken:String, expiry:NSDate? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - accessToken - - -
    -

    The access token.

    - -
    -
    - - expiry - - -
    -

    The optional expiry date.

    - -
    -
    -
    -
    -

    Return Value

    -

    A new instance of UsergridAuth

    - -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(coder:) - -
    -
    -
    -
    -
    -
    -

    NSCoding protocol initializer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    required public init?(coder aDecoder: NSCoder)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - aDecoder - - -
    -

    The decoder.

    - -
    -
    -
    -
    -

    Return Value

    -

    A decoded UsergridAuth object.

    - -
    -
    -
    -
  • -
  • -
    - - - - encodeWithCoder(_:) - -
    -
    -
    -
    -
    -
    -

    NSCoding protocol encoder.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encodeWithCoder(aCoder: NSCoder)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - aCoder - - -
    -

    The encoder.

    - -
    -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - destroy() - -
    -
    -
    -
    -
    -
    -

    Destroys/removes the access token and expiry.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func destroy()
    - -
    -
    -
    -
    -
  • -
-
-
-
- -