use of cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaCredentials in project androidApp by InspectorIncognito.
the class FacebookDataManager method getCredentials.
void getCredentials(final CredentialsListener listener) {
Log.d(TAG, "getUserData");
final AccessToken currentToken = AccessToken.getCurrentAccessToken();
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), "/me", null, HttpMethod.GET, new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
Profile profile = Profile.getCurrentProfile();
String email = response.getJSONObject().getString("email");
String name = response.getJSONObject().getString("name");
String imageUri = profile.getProfilePictureUri(200, 200).toString();
SocialMediaCredentials credentials = new SocialMediaCredentials(currentToken.getToken(), currentToken.getUserId(), FACEBOOK_ACCOUNT, name, email, imageUri);
listener.onSuccess(new FacebookAccount(credentials));
} catch (JSONException | NullPointerException e) {
listener.onError(new ServerStatusCode(ServerStatusCode.LOGIN_API_ERROR));
Log.e(TAG, e.getMessage() == null ? "null message" : e.getMessage());
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email");
request.setParameters(parameters);
request.executeAsync();
}
use of cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaCredentials in project androidApp by InspectorIncognito.
the class GoogleDataManager method getCredentials.
void getCredentials(final CredentialsListener listener, GoogleSignInAccount account, GoogleApiClient mGoogleApiClient) {
Log.d(TAG, "getUserData");
SocialMediaCredentials credentials = new SocialMediaCredentials(account.getIdToken(), account.getId(), GOOGLE_ACCOUNT, account.getDisplayName(), account.getEmail(), account.getPhotoUrl().toString());
listener.onSuccess(new GoogleAccount(credentials, mGoogleApiClient));
}
Aggregations