DBAccessToken

Objective-C

@interface DBAccessToken : NSObject <NSSecureCoding>

Swift

class DBAccessToken : NSObject, NSSecureCoding

A Dropbox OAuth2 access token.

Stores a unique identifying key for storing in DBKeychain.

  • The OAuth2 access token.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull accessToken;

    Swift

    var accessToken: String { get }
  • uid

    The unique identifier of the access token used for storing in DBKeychain. Either the account_id (if user app) or the team_id if (team app).

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull uid;

    Swift

    var uid: String { get }
  • The refresh token if accessToken is short-lived.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *refreshToken;

    Swift

    var refreshToken: String? { get }
  • The expiration time of the (short-lived) accessToken.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSTimeInterval tokenExpirationTimestamp;

    Swift

    var tokenExpirationTimestamp: TimeInterval { get }
  • Creates a DBAccessToken object for a long-lived access token.

    Declaration

    Objective-C

    + (nonnull DBAccessToken *)
        createWithLongLivedAccessToken:(nonnull NSString *)accessToken
                                   uid:(nonnull NSString *)uid;

    Swift

    class func create(withLongLivedAccessToken accessToken: String, uid: String) -> DBAccessToken

    Parameters

    accessToken

    The OAuth2 access token retrieved from the auth flow.

    uid

    The unique identifier used to store in DBKeychain.

    Return Value

    A DBAccessToken object.

  • Creates a DBAccessToken object for a short-lived access token.

    Declaration

    Objective-C

    + (nonnull DBAccessToken *)
        createWithShortLivedAccessToken:(nonnull NSString *)accessToken
                                    uid:(nonnull NSString *)uid
                           refreshToken:(nullable NSString *)refreshToken
               tokenExpirationTimestamp:(NSTimeInterval)tokenExpirationTimestamp;

    Swift

    class func create(withShortLivedAccessToken accessToken: String, uid: String, refreshToken: String?, tokenExpirationTimestamp: TimeInterval) -> DBAccessToken

    Parameters

    accessToken

    The OAuth2 access token retrieved from the auth flow.

    uid

    The unique identifier used to store in DBKeychain.

    refreshToken

    The refresh token if accessToken is short-lived.

    tokenExpirationTimestamp

    The expiration time of the (short-lived) accessToken.

    Return Value

    A DBAccessToken object.

  • Convenience method for initWithAccessToken:uid:refreshToken:tokenExpirationTimestamp: with refreshToken set to nil and tokenExpirationTimestamp set to 0.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithAccessToken:(nonnull NSString *)accessToken
                                            uid:(nonnull NSString *)uid;

    Swift

    init(accessToken: String, uid: String)
  • DBAccessToken full constructor.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithAccessToken:(nonnull NSString *)accessToken
                                            uid:(nonnull NSString *)uid
                                   refreshToken:(nullable NSString *)refreshToken
                       tokenExpirationTimestamp:
                           (NSTimeInterval)tokenExpirationTimestamp;

    Swift

    init(accessToken: String, uid: String, refreshToken: String?, tokenExpirationTimestamp: TimeInterval)

    Parameters

    accessToken

    The OAuth2 access token retrieved from the auth flow.

    uid

    The unique identifier used to store in DBKeychain.

    refreshToken

    The refresh token if accessToken is short-lived.

    tokenExpirationTimestamp

    The expiration time of the (short-lived) accessToken.

    Return Value

    An initialized instance.