# Class AccessToken

java.lang.Object
com.codename1.io.AccessToken

All Implemented Interfaces:
  `Externalizable`

public class AccessToken extends Object implements Externalizable
This class represent an access token.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AccessToken()`

  ###### Since

  `AccessToken(String token, String expires)`
  Constructor with parameters
  `AccessToken(String token, String expires, String refreshToken)`
  Constructor with parameters
  `AccessToken(String token, String expires, String refreshToken, String identityToken)`
  Constructor with parameters

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AccessToken`
  `createWithExpiryDate(String token, Date expiryDate)`

  ###### Parameters

  `boolean`
  `equals(Object obj)`
  `void`
  `externalize(DataOutputStream out)`
  Allows us to store an object state, this method must be implemented in order to save the state of an object
  `String`
  `getExpires()`
  Simple getter
  `Date`
  `getExpiryDate()`
  Gets the expiry date of this token.
  `String`
  `getIdentityToken()`

  ###### Returns

  `String`
  `getObjectId()`
  The object id must be unique, it is used to identify the object when loaded even when it is obfuscated.
  `String`
  `getRefreshToken()`
  Gets refresh token.
  `String`
  `getToken()`
  Simple getter
  `int`
  `getVersion()`
  Returns the version for the current persistance code, the version will be pased to internalized thus allowing the internalize method to recognize classes persisted in older revisions
  `int`
  `hashCode()`
  `void`
  `internalize(int version, DataInputStream in)`
  Loads the object from the input stream and allows deserialization
  `boolean`
  `isExpired()`
  Checks to see if this token is expired.
  `void`
  `setExpiryDate(Date date)`
  Sets the expiry date of this token.
  `void`
  `setIdentityToken(String identityToken)`

  ###### Parameters

  `void`
  `setRefreshToken(String refreshToken)`
  Sets refresh token.
  `String`
  `toString()`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### AccessToken

    public AccessToken(String token, String expires)

    Constructor with parameters

    ###### Parameters

    - `token`: the token string

    - `expires`: the access token expires date

  - ### AccessToken

    public AccessToken(String token, String expires, String refreshToken)
    Constructor with parameters

  - ### AccessToken

    public AccessToken(String token, String expires, String refreshToken, String identityToken)
    Constructor with parameters

  - ### AccessToken

    public AccessToken()

    ###### Since

    7.0

- ## Method Details

  - ### createWithExpiryDate

    public static AccessToken createWithExpiryDate(String token, Date expiryDate)

    ###### Parameters

    - `Token`: The token.

    - `expiryDate`: The expiry date.

    ###### Since

    7.0

  - ### getToken

    public String getToken()

    Simple getter

    ###### Returns

    the token string

  - ### getExpires

    public String getExpires()

    Simple getter

    ###### Returns

    the expires date

  - ### getVersion

    public int getVersion()
    Description copied from interface: `Externalizable`

    Returns the version for the current persistance code, the version will be pased to internalized thus allowing the internalize method to recognize classes persisted in older revisions

    ###### Returns

    version number for the persistant code

    Specified by:
      `getVersion` in interface `Externalizable`

  - ### externalize

    public void externalize(DataOutputStream out) throws IOException
    Description copied from interface: `Externalizable`

    Allows us to store an object state, this method must be implemented in order to save the state of an object

    ###### Parameters

    - `out`: the stream into which the object must be serialized

    ###### Throws

    - `java.io.IOException`: the method may throw an exception
    Specified by:
      `externalize` in interface `Externalizable`
    Throws:
      `IOException`

  - ### internalize

    public void internalize(int version, DataInputStream in) throws IOException
    Description copied from interface: `Externalizable`

    Loads the object from the input stream and allows deserialization

    ###### Parameters

    - `version`: the version the class returned during the externalization processs

    - `in`: the input stream used to load the class

    ###### Throws

    - `java.io.IOException`: the method may throw an exception
    Specified by:
      `internalize` in interface `Externalizable`
    Throws:
      `IOException`

  - ### getRefreshToken

    public String getRefreshToken()

    Gets refresh token.

    ###### Returns

    Refresh token.

    ###### Since

    7.0

  - ### setRefreshToken

    public void setRefreshToken(String refreshToken)

    Sets refresh token.

    ###### Parameters

    - `refreshToken`: The refresh token.

    ###### Since

    7.0

  - ### getObjectId

    public String getObjectId()
    Description copied from interface: `Externalizable`

    The object id must be unique, it is used to identify the object when loaded even when it is obfuscated.

    ###### Returns

    a unique id

    Specified by:
      `getObjectId` in interface `Externalizable`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getExpiryDate

    public Date getExpiryDate()

    Gets the expiry date of this token.

    ###### Returns

    The expiry date of this token or null.

    ###### Since

    7.0

  - ### setExpiryDate

    public void setExpiryDate(Date date)

    Sets the expiry date of this token.

    ###### Parameters

    - `date`: The expiry date of this token.

    ###### Since

    7.0

  - ### isExpired

    public boolean isExpired()

    Checks to see if this token is expired.

    ###### Returns

    False if no expiry date is set or the expiryDate is before the current time.

    ###### Since

    7.0

  - ### getIdentityToken

    public String getIdentityToken()

    ###### Returns

    the identityToken

    ###### Since

    7.0

  - ### setIdentityToken

    public void setIdentityToken(String identityToken)

    ###### Parameters

    - `identityToken`: the identityToken to set

    ###### Since

    7.0