use of com.zype.fire.api.Model.AccessTokenInfoResponse in project zype-firebuilder by zype.
the class ZypeAuthentication method getAccessTokenWithPin.
public static Map<String, Object> getAccessTokenWithPin(String deviceId, String pin) {
AccessTokenResponse responseAccessToken = ZypeApi.getInstance().retrieveAccessTokenWithPin(deviceId, pin);
AccessTokenInfoResponse responseAccessTokenInfo = null;
ConsumerResponse responseConsumer = null;
if (responseAccessToken != null) {
responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
if (responseAccessTokenInfo != null) {
responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
}
} else {
return null;
}
Map<String, Object> result = new HashMap<>();
result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
result.put(RESPONSE_CONSUMER, responseConsumer);
result.put(RESPONSE_IS_DEVICE_LINKED, true);
return result;
}
use of com.zype.fire.api.Model.AccessTokenInfoResponse in project zype-firebuilder by zype.
the class ZypeAuthentication method refreshToken.
private Map<String, Object> refreshToken(ResponseHandler responseHandler) {
AccessTokenResponse responseAccessToken = ZypeApi.getInstance().refreshAccessToken(Preferences.getString(PREFERENCE_REFRESH_TOKEN));
AccessTokenInfoResponse responseAccessTokenInfo = null;
ConsumerResponse responseConsumer = null;
if (responseAccessToken != null) {
responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
if (responseAccessTokenInfo != null) {
responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
}
} else {
return null;
}
Map<String, Object> result = new HashMap<>();
result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
result.put(RESPONSE_CONSUMER, responseConsumer);
result.put(RESPONSE_IS_DEVICE_LINKED, Preferences.getBoolean(PREFERENCE_IS_DEVICE_LINKED));
return result;
}
use of com.zype.fire.api.Model.AccessTokenInfoResponse in project zype-firebuilder by zype.
the class ZypeAuthentication method getAccessToken.
public static Map<String, Object> getAccessToken(String username, String password) {
// Save user name and password for re-login
// TODO: Save encoded password
Preferences.setString(ZypeAuthentication.PREFERENCE_CONSUMER_EMAIL, username);
Preferences.setString(ZypeAuthentication.PREFERENCE_CONSUMER_PASSWORD, password);
AccessTokenResponse responseAccessToken = ZypeApi.getInstance().retrieveAccessToken(username, password);
AccessTokenInfoResponse responseAccessTokenInfo = null;
ConsumerResponse responseConsumer = null;
if (responseAccessToken != null) {
responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
if (responseAccessTokenInfo != null) {
responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
}
} else {
return null;
}
Map<String, Object> result = new HashMap<>();
result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
result.put(RESPONSE_CONSUMER, responseConsumer);
result.put(RESPONSE_IS_DEVICE_LINKED, false);
return result;
}
Aggregations