FBSDKAccessToken Class Reference
Inherits from | NSObject |
Conforms to | FBSDKCopying NSSecureCoding |
Declared in | FBSDKAccessToken.h |
Tasks
-
appID
property -
declinedPermissions
property -
expirationDate
property -
permissions
property -
refreshDate
property -
tokenString
property -
userID
property -
– init
-
+ new
-
– initWithTokenString:permissions:declinedPermissions:appID:userID:expirationDate:refreshDate:
-
– hasGranted:
-
– isEqualToAccessToken:
-
+ currentAccessToken
-
+ setCurrentAccessToken:
-
+ refreshCurrentAccessToken:
Properties
appID
Returns the app ID.
@property (readonly, copy, nonatomic) NSString *appID
Declared In
FBSDKAccessToken.h
declinedPermissions
Returns the known declined permissions.
@property (readonly, copy, nonatomic) NSSet *declinedPermissions
Declared In
FBSDKAccessToken.h
expirationDate
Returns the expiration date.
@property (readonly, copy, nonatomic) NSDate *expirationDate
Declared In
FBSDKAccessToken.h
permissions
Returns the known granted permissions.
@property (readonly, copy, nonatomic) NSSet *permissions
Declared In
FBSDKAccessToken.h
refreshDate
Returns the date the token was last refreshed.
@property (readonly, copy, nonatomic) NSDate *refreshDate
Declared In
FBSDKAccessToken.h
Class Methods
currentAccessToken
Returns the “global” access token that represents the currently logged in user.
+ (FBSDKAccessToken *)currentAccessToken
Discussion
The currentAccessToken
is a convenient representation of the token of the
current user and is used by other SDK components (like FBSDKLoginManager
).
Declared In
FBSDKAccessToken.h
refreshCurrentAccessToken:
Refresh the current access token’s permission state and extend the token’s expiration date, if possible.
+ (void)refreshCurrentAccessToken:(FBSDKGraphRequestHandler)completionHandler
Parameters
- completionHandler
an optional callback handler that can surface any errors related to permission refreshing.
Discussion
On a successful refresh, the currentAccessToken will be updated so you typically only need to
observe the FBSDKAccessTokenDidChangeNotification
notification.
If a token is already expired, it cannot be refreshed.
Declared In
FBSDKAccessToken.h
setCurrentAccessToken:
Sets the “global” access token that represents the currently logged in user.
+ (void)setCurrentAccessToken:(FBSDKAccessToken *)token
Parameters
- token
The access token to set.
Discussion
This will broadcast a notification and save the token to the app keychain.
Declared In
FBSDKAccessToken.h
Instance Methods
hasGranted:
Convenience getter to determine if a permission has been granted
- (BOOL)hasGranted:(NSString *)permission
Parameters
- permission
The permission to check.
Declared In
FBSDKAccessToken.h
initWithTokenString:permissions:declinedPermissions:appID:userID:expirationDate:refreshDate:
Initializes a new instance.
- (instancetype)initWithTokenString:(NSString *)tokenString permissions:(NSArray *)permissions declinedPermissions:(NSArray *)declinedPermissions appID:(NSString *)appID userID:(NSString *)userID expirationDate:(NSDate *)expirationDate refreshDate:(NSDate *)refreshDate
Parameters
- tokenString
the opaque token string.
- permissions
the granted permissions. Note this is converted to NSSet and is only an NSArray for the convenience of literal syntax.
- declinedPermissions
the declined permissions. Note this is converted to NSSet and is only an NSArray for the convenience of literal syntax.
- appID
the app ID.
- userID
the user ID.
- expirationDate
the optional expiration date (defaults to distantFuture).
- refreshDate
the optional date the token was last refreshed (defaults to today).
Discussion
This initializer should only be used for advanced apps that
manage tokens explicitly. Typical login flows only need to use FBSDKLoginManager
along with +currentAccessToken
.
Declared In
FBSDKAccessToken.h