public class VKAccessToken
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACCESS_TOKEN |
java.lang.String |
accessToken
String token for use in request parameters
|
long |
created
Indicates time of token creation
|
static java.lang.String |
CREATED |
java.lang.String |
email
User email
|
static java.lang.String |
EMAIL |
static java.lang.String |
EXPIRES_IN |
int |
expiresIn
Time when token expires
|
static java.lang.String |
HTTPS_REQUIRED |
boolean |
httpsRequired
If user sets "Always use HTTPS" setting in his profile, it will be true
|
static java.lang.String |
SCOPE |
java.lang.String |
secret
User secret to sign requests (if nohttps used)
|
static java.lang.String |
SECRET |
static java.lang.String |
SUCCESS |
static java.lang.String |
USER_ID |
java.lang.String |
userId
Current user id for this token
|
| Modifier and Type | Method and Description |
|---|---|
VKAccessToken |
copyWithToken(VKAccessToken token)
Creates copy of current token, with params from passed token
|
static VKAccessToken |
currentToken() |
boolean |
hasScope(java.lang.String... scopes)
Return if this token contains passed permissions array
|
boolean |
isExpired()
Checks expiration time of token and returns result.
|
static void |
removeTokenAtKey(android.content.Context ctx,
java.lang.String tokenKey)
Removes token from preferences with specified key
|
void |
save()
Saves this token into application shared preferences
|
void |
saveTokenToFile(java.lang.String filePath)
Save token into specified file
|
void |
saveTokenToSharedPreferences(android.content.Context ctx,
java.lang.String tokenKey)
Save token into shared preferences with key
|
protected java.lang.String |
serialize()
Serialize token into string
|
static VKAccessToken |
tokenFromFile(java.lang.String filePath)
Retrieve token from file.
|
static VKAccessToken |
tokenFromParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
Retrieve token from key-value map
|
static VKAccessToken |
tokenFromSharedPreferences(android.content.Context ctx,
java.lang.String key)
Retrieves token from shared preferences
|
static VKAccessToken |
tokenFromUrlString(java.lang.String urlString)
Retrieve token from key-value query string
|
protected java.util.Map<java.lang.String,java.lang.String> |
tokenParams()
Serialize token to VKParameters
|
public static final java.lang.String ACCESS_TOKEN
public static final java.lang.String EXPIRES_IN
public static final java.lang.String USER_ID
public static final java.lang.String SECRET
public static final java.lang.String HTTPS_REQUIRED
public static final java.lang.String CREATED
public static final java.lang.String SUCCESS
public static final java.lang.String EMAIL
public static final java.lang.String SCOPE
public java.lang.String accessToken
public int expiresIn
public java.lang.String userId
public java.lang.String secret
public boolean httpsRequired
public long created
public java.lang.String email
public void saveTokenToFile(java.lang.String filePath)
filePath - path to file with saved tokenpublic void saveTokenToSharedPreferences(android.content.Context ctx,
java.lang.String tokenKey)
ctx - Context for preferencestokenKey - Key for saving settingspublic static void removeTokenAtKey(android.content.Context ctx,
java.lang.String tokenKey)
ctx - Context for preferencestokenKey - Key for saving settingsprotected java.util.Map<java.lang.String,java.lang.String> tokenParams()
protected java.lang.String serialize()
public static VKAccessToken tokenFromUrlString(java.lang.String urlString)
urlString - string that contains URL-query part with token. E.g. access_token=eee&expires_in=0...public static VKAccessToken tokenFromParameters(@Nullable java.util.Map<java.lang.String,java.lang.String> parameters)
parameters - map that contains token infopublic static VKAccessToken tokenFromSharedPreferences(android.content.Context ctx, java.lang.String key)
ctx - Context for preferenceskey - Key for retrieve tokenpublic static VKAccessToken tokenFromFile(java.lang.String filePath)
filePath - path to file with saved tokenpublic boolean isExpired()
public static VKAccessToken currentToken()
public void save()
public boolean hasScope(java.lang.String... scopes)
scopes - permissions to checkpublic VKAccessToken copyWithToken(@NonNull VKAccessToken token)
token - Usually this is partly filled access token, made after validation