Java 类com.facebook.AccessToken 实例源码

项目:kognitivo    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    GraphRequest.ParcelableResourceWithMimeType<ParcelFileDescriptor> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(descriptor, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:kognitivo    文件:VideoUploader.java   
private static void registerAccessTokenTracker() {
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {
            if (oldAccessToken == null) {
                // If we never had an access token, then there would be no pending uploads.
                return;
            }

            if (currentAccessToken == null ||
                    !Utility.areObjectsEqual(
                            currentAccessToken.getUserId(),
                            oldAccessToken.getUserId())) {
                // Cancel any pending uploads since the user changed.
                cancelAllRequests();
            }
        }
    };
}
项目:kognitivo    文件:VideoUploader.java   
private UploadContext(
        ShareVideoContent videoContent,
        String graphNode,
        FacebookCallback<Sharer.Result> callback) {
    // Store off the access token right away so that under no circumstances will we
    // end up with different tokens between phases. We will rely on the access token tracker
    // to cancel pending uploads.
    this.accessToken = AccessToken.getCurrentAccessToken();
    this.videoUri = videoContent.getVideo().getLocalUrl();
    this.title = videoContent.getContentTitle();
    this.description = videoContent.getContentDescription();
    this.ref = videoContent.getRef();
    this.graphNode = graphNode;
    this.callback = callback;
    this.params = videoContent.getVideo().getParameters();
}
项目:kognitivo    文件:ShareApi.java   
/**
 * Returns true if the content can be shared. Warns if the access token is missing the
 * publish_actions permission. Doesn't fail when this permission is missing, because the app
 * could have been granted that permission in another installation.
 *
 * @return true if the content can be shared.
 */
public boolean canShare() {
    if (this.getShareContent() == null) {
        return false;
    }
    final AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken == null) {
        return false;
    }
    final Set<String> permissions = accessToken.getPermissions();
    if (permissions == null || !permissions.contains("publish_actions")) {
        Log.w(TAG, "The publish_actions permissions are missing, the share will fail unless" +
                " this app was authorized to publish in another installation.");
    }

    return true;
}
项目:kognitivo    文件:ShareApi.java   
private void shareLinkContent(final ShareLinkContent linkContent,
                              final FacebookCallback<Sharer.Result> callback) {
    final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            final JSONObject data = response.getJSONObject();
            final String postId = (data == null ? null : data.optString("id"));
            ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
        }
    };
    final Bundle parameters = new Bundle();
    this.addCommonParameters(parameters, linkContent);
    parameters.putString("message", this.getMessage());
    parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
    parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
    parameters.putString("name", linkContent.getContentTitle());
    parameters.putString("description", linkContent.getContentDescription());
    parameters.putString("ref", linkContent.getRef());
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            getGraphPath("feed"),
            parameters,
            HttpMethod.POST,
            requestCallback).executeAsync();
}
项目:kognitivo    文件:LoginMethodHandler.java   
static AccessToken createAccessTokenFromNativeLogin(
        Bundle bundle,
        AccessTokenSource source,
        String applicationId) {
    Date expires = Utility.getBundleLongAsDate(
            bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, new Date(0));
    ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
    String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);

    if (Utility.isNullOrEmpty(token)) {
        return null;
    }

    String userId = bundle.getString(NativeProtocol.EXTRA_USER_ID);

    return new AccessToken(
            token,
            applicationId,
            userId,
            permissions,
            null,
            source,
            expires,
            new Date());
}
项目:kognitivo    文件:LoginClient.java   
void authorize(Request request) {
    if (request == null) {
        return;
    }

    if (pendingRequest != null) {
        throw new FacebookException("Attempted to authorize while a request is pending.");
    }

    if (AccessToken.getCurrentAccessToken() != null && !checkInternetPermission()) {
        // We're going to need INTERNET permission later and don't have it, so fail early.
        return;
    }
    pendingRequest = request;
    handlersToTry = getHandlersToTry(request);
    tryNextHandler();
}
项目:kognitivo    文件:LoginManager.java   
static LoginResult computeLoginResult(
        final LoginClient.Request request,
        final AccessToken newToken
) {
    Set<String> requestedPermissions = request.getPermissions();
    Set<String> grantedPermissions = new HashSet<String>(newToken.getPermissions());

    // If it's a reauth, subset the granted permissions to just the requested permissions
    // so we don't report implicit permissions like user_profile as recently granted.
    if (request.isRerequest()) {
        grantedPermissions.retainAll(requestedPermissions);
    }

    Set<String> deniedPermissions = new HashSet<String>(requestedPermissions);
    deniedPermissions.removeAll(grantedPermissions);
    return new LoginResult(newToken, grantedPermissions, deniedPermissions);
}
项目:GodotFireBase    文件:FacebookSignIn.java   
public void getPermissions() {
    String uri = "me/permissions/";

    new GraphRequest(AccessToken.getCurrentAccessToken(),
    uri, null, HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
                /* handle the result */
                JSONArray data = response.getJSONObject().optJSONArray("data");
                mUserPermissions.clear();

                for (int i = 0; i < data.length(); i++) {
                    JSONObject dd = data.optJSONObject(i);

                    if (dd.optString("status").equals("granted")) {
                        mUserPermissions
                        .add(dd.optString("permission"));
                    }
                }
            }
        }
    ).executeAsync();
}
项目:GodotFireBase    文件:FacebookSignIn.java   
public void revokePermission(final String permission) {
    AccessToken token = AccessToken.getCurrentAccessToken();

    String uri = "me/permissions/" + permission;

    GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
    token, uri, new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            FacebookRequestError error = response.getError();
            if (error == null) {
                Utils.d("FB:Revoke:Response:" + response.toString());
                getPermissions();
            }
        }
    });

    graphRequest.executeAsync();
}
项目:GodotFireBase    文件:FacebookSignIn.java   
/** GraphRequest **/

    public void revokeAccess() {
        mAuth.signOut();

        AccessToken token = AccessToken.getCurrentAccessToken();
        GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
        token, "me/permissions", new GraphRequest.Callback() {
            @Override
            public void onCompleted(GraphResponse response) {
                FacebookRequestError error = response.getError();
                if (error == null) {
                    Utils.d("FB:Delete:Access" + response.toString());
                }
            }
        });

        graphRequest.executeAsync();
    }
项目:GodotFireBase    文件:FacebookSignIn.java   
public void handleAccessToken(AccessToken token) {
    Utils.d("FB:Handle:AccessToken: " + token.getToken());
    // showProgressDialog();

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());

    mAuth.signInWithCredential(credential)
    .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {

        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            Utils.d("FB:signInWithCredential:onComplete:" + task.isSuccessful());

            // If sign in fails, display a message to the user. If sign in succeeds
            // the auth state listener will be notified and logic to handle the
            // signed in user can be handled in the listener.

            if (!task.isSuccessful()) {
                Utils.w("FB:signInWithCredential" + 
                    task.getException().toString());
            }

            // hideProgressDialog();
        }
    });
}
项目:GodotFireBase    文件:FacebookSignIn.java   
protected void successLogin (FirebaseUser user) {
    Utils.d("FB:Login:Success");

    isFacebookConnected = true;
    accessToken = AccessToken.getCurrentAccessToken();

    try {
        currentFBUser.put("name", user.getDisplayName());
        currentFBUser.put("email_id", user.getEmail());
        currentFBUser.put("photo_uri", user.getPhotoUrl());
        currentFBUser.put("token", accessToken.getToken().toString());

    } catch (JSONException e) { Utils.d("FB:JSON:Error:" + e.toString()); }

    getPermissions();

    // call Script
    Utils.callScriptFunc("Auth", "FacebookLogin", "true");
}
项目:furry-sniffle    文件:RegisterActivity.java   
private void FirebaseAuthWithFacebook(AccessToken token) {
    //Log.d(TAG, "FirebaseAuthWithFacebook:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {

                    if (task.isSuccessful()) {
                        // Sign in success.
                        //Log.d(TAG, "signInWithCredential:success");
                        Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
                        mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        mProgressDialog.dismiss();
                        startActivity(mainIntent);
                        finish();
                    } else {
                        // Sign in failed
                        //Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(RegisterActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:furry-sniffle    文件:LoginActivity.java   
private void FirebaseAuthWithFacebook(AccessToken token) {
    //Log.d(TAG, "FirebaseAuthWithFacebook:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {

                    if (task.isSuccessful()) {
                        // Sign in success.
                        //Log.d(TAG, "signInWithCredential:success");
                        Intent mainIntent = new Intent(LoginActivity.this, MainActivity.class);
                        mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        mProgressDialog.dismiss();
                        startActivity(mainIntent);
                        finish();
                    } else {
                        // Sign in failed
                        //Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Snackbar.make(mConstraintLayout, "Facebook Connection Failed.", Snackbar.LENGTH_LONG ).show();
                    }

                }
            });
}
项目:android-paypal-example    文件:LoginActivity.java   
private void handleFacebookAccessToken(AccessToken token) {

        Log.d(TAG, "handleFacebookAccessToken:" + token);

        AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            Log.d(TAG, "signInWithCredential:success");
                            updateUI(mAuth.getCurrentUser());
                        } else {
                            // If sign in fails, display a message to the user.
                            Log.w(TAG, "signInWithCredential:failure", task.getException());
                            Toast.makeText(LoginActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }

                    }
                });
    }
项目:WaJeun    文件:MainActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
}
项目:Stalker    文件:AuthenticateFragment.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    fireBaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(getApplicationContext(), "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:GDFacebook    文件:FacebookSDK.java   
public void loadRequests() {
    AccessToken token = AccessToken.getCurrentAccessToken();

    GraphRequest myRequests = GraphRequest.newGraphPathRequest(
    token, "/me/apprequests", new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            FacebookRequestError error = response.getError();

            if (error == null) {
                JSONObject graphObject = response.getJSONObject();
                JSONArray data = graphObject.optJSONArray("data");

                Utils.callScriptFunc("pendingRequest", data.toString());
            } else { Utils.d("Response Error: " + error.toString()); }
        }
    });

    myRequests.executeAsync();
}
项目:GDFacebook    文件:FacebookSDK.java   
public static void deleteRequest (String requestId) {
    // delete Requets here GraphAPI.
    Utils.d("Deleting:Request:" + requestId);

    AccessToken token = AccessToken.getCurrentAccessToken();
    GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
    token, requestId, new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            FacebookRequestError error = response.getError();
            if (error == null) { Utils.d("OnDelete:Req:" + response.toString()); }
        }
    });

    graphRequest.executeAsync();
}
项目:GDFacebook    文件:FacebookSDK.java   
public static void getUserDataFromRequest (String requestId) {
    // Grah Api to get user data from request.

    AccessToken token = AccessToken.getCurrentAccessToken();
    GraphRequest graphRequest = GraphRequest.newGraphPathRequest(
    token, requestId, new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            FacebookRequestError error = response.getError();

            if (error == null) { Utils.d("Response: " + response.toString()); }
            else { Utils.d("Error: " + response.toString()); }
        }
    });

    graphRequest.executeAsync();
}
项目:apn_fb_login    文件:ApnFbLoginPlugin.java   
private void queryMe(Result result) {
    GraphRequest request = GraphRequest.newMeRequest(
            AccessToken.getCurrentAccessToken(),
            (object, response) -> {
                try {
                    result.success(JsonConverter.convertToMap(object));
                } catch (JSONException e) {
                    result.error(TAG, "Error", e.getMessage());
                }
            });

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email");
    request.setParameters(parameters);
    request.executeAsync();
}
项目:CollegeDoc    文件:MainActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:CollegeDoc    文件:MainActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:social-app-android    文件:LoginActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    LogUtil.logDebug(TAG, "handleFacebookAccessToken:" + token);
    showProgress();

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        handleAuthError(task);
                    }
                }
            });
}
项目:FirebasePost    文件:RegisterActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.e(TAG, "handleFacebookAccessToken:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.e(TAG, "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUser(user);
                        updateUi();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.e(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(RegisterActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }

            });
}
项目:Project-Chao    文件:AuthDialogFragment.java   
private void handleFacebookAccessToken(AccessToken token) {
  Log.d(TAG, "handleFacebookAccessToken:" + token);
  // [START_EXCLUDE silent]
  // showProgressDialog();
  // [END_EXCLUDE]
  AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
  mAuth.signInWithCredential(credential)
      .addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
        @Override public void onComplete(@NonNull Task<AuthResult> task) {
          Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

          // If sign in fails, display a message to the user. If sign in succeeds
          // the auth state listener will be notified and logic to handle the
          // signed in user can be handled in the listener.
          if (!task.isSuccessful()) {
            Log.w(TAG, "signInWithCredential", task.getException());
            Toast.makeText(getContext(), "Authentication failed.", Toast.LENGTH_SHORT).show();
          }
          // [START_EXCLUDE]
          // hideProgressDialog();
          dismiss();
          // [END_EXCLUDE]
        }
      });
}
项目:journal    文件:FbPageInfoFragment.java   
public void pageAbout(final String pageId){

        GraphRequest request = GraphRequest.newGraphPathRequest(
                AccessToken.getCurrentAccessToken(),
                "/"+pageId,
                new GraphRequest.Callback() {
                    @Override
                    public void onCompleted(GraphResponse response) {
                        JSONObject object = response.getJSONObject();
                        String about = object.optString("about");
                        pageAbout_tv = (TextView)getActivity().findViewById(R.id.pageAbout);
                        pageAbout_tv.setText(about);
                        String description = object.optString("description");
                        pageAbout_tv = (TextView)getActivity().findViewById(R.id.pageDescription);
                        pageAbout_tv.setText(about);
                    }
                });

        Bundle parameters = new Bundle();
        parameters.putString("fields", "about,description");
        request.setParameters(parameters);
        request.executeAsync();

    }
项目:zum-android    文件:SignUpActivity.java   
private void getUserEmail(AccessToken accessToken) {
    GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            try {
                updateUserData(object.getString("email"));
            } catch (JSONException e) {
                updateUserData("");
                e.printStackTrace();
            }
        }
    });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,email");
    request.setParameters(parameters);
    request.executeAsync();
}
项目:uPods-android    文件:LoginMaster.java   
public void logout() {
    if (AccessToken.getCurrentAccessToken() != null) {
        LoginManager.getInstance().logOut();
        Logger.printInfo(LOG_TAG, "Loged out from facebook");
    }
    if (Twitter.getSessionManager().getActiveSession() != null) {
        Twitter.getSessionManager().clearActiveSession();
        Twitter.logOut();
        Logger.printInfo(LOG_TAG, "Loged out from twitter");
    }
    if (VKSdk.isLoggedIn()) {
        VKSdk.logout();
        Logger.printInfo(LOG_TAG, "Loged out from vk");
    }
    Prefs.remove(SyncMaster.GLOBAL_TOKEN);
    userProfile = new UserProfile();
}
项目:uPods-android    文件:LoginMaster.java   
public void initUserProfile(final IOperationFinishWithDataCallback profileFetched, boolean isForceUpdate) {
    if (userProfile != null && !isForceUpdate) {
        profileFetched.operationFinished(userProfile);
    } else if (!isLogedIn()) {
        userProfile = new UserProfile();
        profileFetched.operationFinished(userProfile);
    } else {
        if (AccessToken.getCurrentAccessToken() != null) {
            fetchFacebookUserData(profileFetched);
        } else if (Twitter.getSessionManager().getActiveSession() != null) {
            fetchTwitterUserData(profileFetched);
        } else if (VKSdk.isLoggedIn()) {
            fetchVkUserData(profileFetched);
        }
    }
}
项目:AndroidAllStars    文件:GuestActivity.java   
@Override
public void endSession() {
    if (AccessToken.getCurrentAccessToken() != null) {
        LoginManager.getInstance().logOut();
    }

    TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession();
    if (twitterSession != null) {
        clearCookies(getApplicationContext());
        Twitter.getSessionManager().clearActiveSession();
        Twitter.logOut();
    }

    startActivity(LoginActivity.makeIntent(this));
    finish();
}
项目:PagesManager    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    mCallbackManager = CallbackManager.Factory.create();
    setContentView(R.layout.activity_main);
    initViews();


    if (AccessToken.getCurrentAccessToken() == null) {
        //user not logged in
        hideViewsAfterLogout();
    } else {
        //user logged in
        getAvailablePagesAsync();

    }
}
项目:YalantisInternship    文件:RealmManager.java   
@Override
public AccessToken getToken() {

    TokenRealm tokenRealm = mDatabaseRealm.getToken();

    if (tokenRealm == null) {
        return null;
    }

    return new AccessToken(tokenRealm.getToken(),
            tokenRealm.getAppId(),
            tokenRealm.getUserId(),
            tokenRealm.getPermissionsList(),
            tokenRealm.getDeclinedPermissionsList(),
            AccessTokenSource.valueOf(tokenRealm.getTokenSource()),
            new Date(tokenRealm.getExpirationDate()),
            new Date(tokenRealm.getLastRefreshTime()));
}
项目:YalantisInternship    文件:MainActivity.java   
/**
 * Updated buttons in the Navigation Drawer according to a state
 */
private void updateDrawer() {
    // select first item in navigation drawer on startup
    Menu drawerMenu = mNavigationView.getMenu();
    drawerMenu.getItem(0).setChecked(true);

    // set correct visibility of we are logged in or logged out
    MenuItem facebookProfile = drawerMenu.findItem(R.id.profile_button);
    MenuItem login = drawerMenu.findItem(R.id.login_button);
    if (facebookProfile != null) {
        if (AccessToken.getCurrentAccessToken() != null) {
            login.setVisible(false);
            facebookProfile.setVisible(true);
        } else {
            login.setVisible(true);
            facebookProfile.setVisible(false);
        }
    }
}
项目:SocialLoginManager    文件:FbLoginHiddenActivity.java   
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
  try {
    SocialUser user = new SocialUser();
    user.userId = object.getString("id");
    user.accessToken = AccessToken.getCurrentAccessToken().getToken();
    user.photoUrl = String.format(PHOTO_URL, user.userId);
    SocialUser.Profile profile = new SocialUser.Profile();
    profile.email = object.has("email")? object.getString("email") : "";
    profile.name = object.has("name")? object.getString("name"): "";
    profile.pageLink = object.has("link")? object.getString("link"): "";
    user.profile = profile;
    SocialLoginManager.getInstance(this).onLoginSuccess(user);
  } catch (JSONException e) {
    SocialLoginManager.getInstance(this).onLoginError(e.getCause());
  }

  LoginManager.getInstance().logOut();

  finish();
}
项目:survey-android    文件:LoginTempActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    auth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (!task.isSuccessful()) {
                        Toast.makeText(LoginTempActivity.this, R.string.error_auth,
                                Toast.LENGTH_SHORT).show();
                        showMainScreen();
                    }else{
                        FirebaseUser firebaseUser = task.getResult().getUser();
                        User user = new User();
                        user.setDisplayName(firebaseUser.getDisplayName());
                        user.setEmail(firebaseUser.getEmail());
                        user.setId(firebaseUser.getUid());
                        if(firebaseUser.getPhotoUrl() != null){
                            user.setProfileImageURL(firebaseUser.getPhotoUrl().toString());
                        }
                        user.setToken(user.getToken());
                        repository.saveUser(user);
                        showMainScreen();
                    }
                }
            });
}
项目:The_Elucidated    文件:SignInLoadActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInLoadActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                    // ...
                }
            });
}
项目:survey-android    文件:RegisterActivity.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d("hfat", "handleFacebookAccessToken:" + token);

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    auth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d("hfat - o", "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w("hfat - o is", "signInWithCredential", task.getException());
                        Toast.makeText(RegisterActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
}
项目:HaiNaBaiChuan    文件:LoginPresenter.java   
@Override
public void requestFacebook(LoginResult loginResult) {
    AccessToken accessToken = loginResult.getAccessToken();
    NetRequest.Instance().facebookLogin(accessToken.getUserId(), MD5Util.getMD5(accessToken.getUserId()),
            new NetRequest.RequestListener<User>() {
                @Override
                public void success(User user) {
                    view.callLoginSuccess();
                }

                @Override
                public void error(String err) {
                    view.callLoginFail(err);
                }
            });

}