Skip to main content
The AccessToken class represents an immutable access token for using Facebook services. It provides methods to retrieve, manage, and monitor access tokens.
Access Tokens are not available with Limited Login on iOS. Use AuthenticationToken instead.

Import

Static Methods

getCurrentAccessToken

Retrieves the current access token for the application.

Returns

Promise<AccessToken | null> - Resolves with an AccessToken instance if a user is logged in, or null if no user is logged in.

Example


setCurrentAccessToken

Sets the current access token for the application.

Parameters

This method is for advanced use cases only. Most apps should not need to call this directly.

Example


refreshCurrentAccessTokenAsync

Refreshes the current access token, extending expiration date if possible.

Returns

Promise<AccessTokenMap> - Resolves with the refreshed access token data.

Example


addListener

Adds a listener that is called when the access token changes.

Parameters

Returns

() => void - A function that removes the listener when called.

Example

Instance Properties

accessToken

The access token string.

Example


permissions

Array of permissions that have been granted.

Example


declinedPermissions

Array of permissions that have been declined by the user.

Example


expiredPermissions

Array of permissions that have expired.

Example


applicationID

The Facebook App ID associated with this token.

Example


userID

The Facebook User ID associated with this token.

Example


expirationTime

The expiration time of the access token (milliseconds since epoch).

Example


lastRefreshTime

The last time the token was refreshed (milliseconds since epoch).

Example


dataAccessExpirationTime

The data access expiration time (milliseconds since epoch).

Example


accessTokenSource

The source of the access token (Android only).
Platform: Android only

Example

Instance Methods

getExpires

Gets the expiration time of the access token.

Returns

number - Expiration time in milliseconds since epoch.

Example


getPermissions

Gets the list of granted permissions.

Returns

Array<string> - Array of granted permission strings.

Example


getDeclinedPermissions

Gets the list of declined permissions.

Returns

Array<string> - Array of declined permission strings.

Example


getExpiredPermissions

Gets the list of expired permissions.

Returns

Array<string> - Array of expired permission strings.

Example


getLastRefresh

Gets the last refresh time of the token.

Returns

number - Last refresh time in milliseconds since epoch.

Example


getDataAccessExpiration

Gets the data access expiration time.

Returns

number - Data access expiration time in milliseconds since epoch.

Example


getApplicationId

Gets the Facebook App ID.

Returns

string - The Facebook App ID.

Example


getUserId

Gets the Facebook User ID.

Returns

string - The Facebook User ID.

Example

Types

AccessTokenMap

Represents the raw access token data returned from the native SDK.

Complete Example

See Also

Authentication

Learn about Facebook authentication

LoginManager

Perform login operations

AuthenticationToken

iOS Limited Login authentication tokens

Graph API

Make Graph API requests