public static LoginOAuth login(Activity activity) { return new LoginOAuth(new GoogleOAuth(activity), DEFAULT_SCOPES); }
public static LogoutOAuth logout(Activity activity) { return new LogoutOAuth(new GoogleOAuth(activity)); }
public static LoginOAuth login(Activity activity) { return new LoginOAuth(new FacebookOAuth(activity), DEFAULT_SCOPES); }
public void googleLogin(View v) { GoogleOAuth.login(this) .setClientId(Credentials.GOOGLE_CLIENT_ID) .setClientSecret(Credentials.GOOGLE_CLIENT_SECRET) .setAdditionalScopes("https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/user.birthday.read") .setRedirectUri(Credentials.GOOGLE_REDIRECT_URI) .setCallback(new OnLoginCallback() { @Override public void onSuccess(String token, SocialUser user) { afterLogin(token, user); } @Override public void onError(Exception error) { error.printStackTrace(); } }) .init(); }
public void facebookLogin(View v) { FacebookOAuth.login(this) .setClientId(Credentials.FACEBOOK_APP_ID) .setClientSecret(Credentials.FACEBOOK_APP_SECRET) .setAdditionalScopes("user_friends user_birthday") .setRedirectUri(Credentials.FACEBOOK_REDIRECT_URI) .setCallback(new OnLoginCallback() { @Override public void onSuccess(String token, SocialUser user) { afterLogin(token, user); } @Override public void onError(Exception error) { error.printStackTrace(); } }) .init(); }
switch (currentProvider) { case GOOGLE: GoogleOAuth.logout(this) .setToken(currentToken) .setCallback(callback) .init(); break; case FACEBOOK: FacebookOAuth.logout(this) .setToken(currentToken) .setCallback(callback) .init(); break;
public static LogoutOAuth logout(Activity activity) { return new LogoutOAuth(new FacebookOAuth(activity)); }
protected SocialUser(Parcel in) { this.id = in.readString(); this.name = in.readString(); this.email = in.readString(); this.pictureUrl = in.readString(); this.coverUrl = in.readString(); long tmpBirthday = in.readLong(); this.birthday = tmpBirthday == -1 ? null : new Date(tmpBirthday); int tmpProvider = in.readInt(); this.provider = tmpProvider == -1 ? null : OAuthProvider.values()[tmpProvider]; }
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.id); dest.writeString(this.name); dest.writeString(this.email); dest.writeString(this.pictureUrl); dest.writeString(this.coverUrl); dest.writeLong(this.birthday != null ? this.birthday.getTime() : -1); dest.writeInt(this.provider == null ? -1 : this.provider.ordinal()); }
private SocialUser getAccount(OAuth20Service service, OAuth2AccessToken accessToken) { try { OAuthRequest request = new OAuthRequest(Verb.GET, getAccountUrl, service); service.signRequest(accessToken, request); Response response = request.send(); return toAccount(response.getBody()); } catch (Exception e) { return null; } }