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.

This function must be run from the UI thread.

public static void refreshCurrentAccessTokenAsync()
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