AccessToken

This class represents an immutable access token for using Facebook APIs. It also includes associated metadata such as expiration date and permissions.

For more information on access tokens, see Access Tokens.

ขยาย:Object
การนำไปใช้:Parcelable
แพ็คเกจ:facebook
ผู้สร้าง
AccessToken(String, String, String, Collection, Collection, AccessTokenSource, Date, Date)

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). Note that the caller is asserting that all parameters provided are correct with respect to the access token string; no validation is done to verify they are correct.

public AccessToken(String accessToken, String applicationId, String userId, Collection permissions, Collection declinedPermissions, AccessTokenSource accessTokenSource, Date expirationTime, Date lastRefreshTime)
พารามิเตอร์คำอธิบาย
accessTokenThe access token string obtained from Facebook
applicationIdThe ID of the Facebook Application associated with this access token
userIdThe id of the user
permissionsThe permissions that were requested when the token was obtained (or when it was last reauthorized); may be null if permission set is unknown
declinedPermissionsThe permissions that were declined when the token was obtained; may be null if permission set is unknown
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.
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.
วิธีการคลาส
getCurrentAccessToken()

Getter for the access token that is current for the application.

public static AccessToken getCurrentAccessToken()
Returns
The access token that is current for the application.
setCurrentAccessToken(AccessToken)

Setter for the access token that is current for the application.

public static void setCurrentAccessToken(AccessToken accessToken)
พารามิเตอร์คำอธิบาย
accessTokenThe access token to set.
refreshCurrentAccessTokenAsync()

Updates the current access token with up to date permissions, and extends the expiration date, if extension is possible.

public static void refreshCurrentAccessTokenAsync()
refreshCurrentAccessTokenAsync(AccessTokenRefreshCallback)

Updates the current access token with up to date permissions, and extends the expiration date, if extension is possible.

public static void refreshCurrentAccessTokenAsync(AccessTokenRefreshCallback callback)
พารามิเตอร์คำอธิบาย
callback
createFromNativeLinkingIntent(Intent, String, AccessTokenCreationCallback)

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 void createFromNativeLinkingIntent(Intent intent, String applicationId, AccessTokenCreationCallback accessTokenCallback)
พารามิเตอร์คำอธิบาย
intentThe Intent that was used to start an Activity; must not be null
applicationIdThe ID of the Facebook Application associated with this access token
accessTokenCallback
วิธีการแบบอินสแตนซ์
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 Facebook, 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 Set 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 Facebook, so this list may be outdated if permissions have been granted or declined since the last time an AccessToken object was created.

public Set 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
getApplicationId()

Gets the ID of the Facebook Application associated with this access token.

public String getApplicationId()
Returns
The application ID
getUserId()

Returns the user id for this access token.

public String getUserId()
Returns
The user id for this access token.
isExpired()

Shows if the token is expired.

public boolean isExpired()
Returns
True if the token is expired.
describeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

public int describeContents()
Returns
A bitmask indicating the set of special object types marshalled by the Parcelable.
describeContents()
public int describeContents()
writeToParcel(Parcel, int)

Flatten this object in to a Parcel.

public void writeToParcel(Parcel dest, int flags)
พารามิเตอร์คำอธิบาย
destThe Parcel in which the object should be written.
flagsAdditional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
writeToParcel(Parcel, int)
public void writeToParcel(Parcel dest, int flags)
พารามิเตอร์คำอธิบาย
dest
flags
ค่าคงตัว
ACCESS_TOKEN_KEY
public static final String ACCESS_TOKEN_KEY
EXPIRES_IN_KEY
public static final String EXPIRES_IN_KEY
USER_ID_KEY
public static final String USER_ID_KEY
CREATOR
public static final Creator CREATOR