AccessToken
Une version plus récente de cette classe est disponible. Rendez-vous sur la dernière version.

This class represents an access token returned by the Facebook Login service, along with associated metadata such as its expiration date and permissions. In general, the Session class will abstract away the need to worry about the details of an access token, but there are situations (such as handling native links, importing previously-obtained access tokens, etc.) where it is useful to deal with access tokens directly. Factory methods are provided to construct access tokens.

For more information on access tokens, see Access Tokens.

Prolonge :Object
Implémentations :Serializable
Package :facebook
Méthodes Class
createFromExistingAccessToken(String, Date, Date, AccessTokenSource, List)

Creates a new AccessToken using the supplied information from a previously-obtained access token (for instance, from an already-cached access token obtained prior to integration with the Facebook SDK).

public static AccessToken createFromExistingAccessToken(String accessToken, Date expirationTime, Date lastRefreshTime, AccessTokenSource accessTokenSource, List permissions)
ParamètreDescription
accessTokenThe access token string obtained from Facebook
expirationTimeThe expiration date associated with the token; if null, an infinite expiration time is assumed (but will become correct when the token is refreshed)
lastRefreshTimeThe last time the token was refreshed (or when it was first obtained); if null, the current time is used.
accessTokenSourceAn enum indicating how the token was originally obtained (in most cases, this will be either AccessTokenSource.FACEBOOK_APPLICATION or AccessTokenSource.WEB_VIEW); if null, FACEBOOK_APPLICATION is assumed.
permissionsThe permissions that were requested when the token was obtained (or when it was last reauthorized); may be null if permission set is unknown
Returns
A new AccessToken
createFromNativeLinkingIntent(Intent)

Creates a new AccessToken using the information contained in an Intent populated by the Facebook application in order to launch a native link. For more information on native linking, please see https://developers.facebook.com/docs/mobile/android/deep_linking/.

public static AccessToken createFromNativeLinkingIntent(Intent intent)
ParamètreDescription
intentThe Intent that was used to start an Activity; must not be null
Returns
A new AccessToken, or null if the Intent did not contain enough data to create one
Méthodes d’instance
getToken()

Gets the string representing the access token.

public String getToken()
Returns
The string representing the access token
getExpires()

Gets the date at which the access token expires.

public Date getExpires()
Returns
The expiration date of the token
getPermissions()

Gets the list of permissions associated with this access token. Note that the most up-to-date list of permissions is maintained by the Facebook service, so this list may be outdated if permissions have been added or removed since the time the AccessToken object was created. For more information on permissions, see https://developers.facebook.com/docs/reference/login/#permissions.

public List getPermissions()
Returns
A read-only list of strings representing the permissions granted via this access token
getDeclinedPermissions()

Gets the list of permissions declined by the user with this access token. It represents the entire set of permissions that have been requested and declined. Note that the most up-to-date list of permissions is maintained by the Facebook service, so this list may be outdated if permissions have been granted or declined since the last time an AccessToken object was created.

public List getDeclinedPermissions()
Returns
A read-only list of strings representing the permissions declined by the user
getSource()

Gets the AccessTokenSource indicating how this access token was obtained.

public AccessTokenSource getSource()
Returns
The enum indicating how the access token was obtained
getLastRefresh()

Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK will attempt to renew them periodically.

public Date getLastRefresh()
Returns
The date at which this token was last refreshed