I am developing an app which uses facebook integration. I am trying to receive the access_token and expires_in tokens from the facebook library classes. Once i am logged in I get the access_token correctly but i always get expires_in token always 0. And because of that I isSessionValid() method always returns false. Kindly let me know if anyone has faced this issue and solved it.
My code runs perfectly fine when i do not have the Facebook app installed in the emulator. I get the webview and I can log in and update status. But when I install Facebook app, clicking on the update status menu option opens the Facebook app, I get redirected to the permissions page and then I get an error saying " Failed to receive access token". This is infact because of the expires_in token being 0.
i do not want to ask the users of the app to uninstall the Facebook app if they have installed. kindly let me the solution to this problem.
Thanks,
Punit
If you put permission offline_access, the token expiry is 0.
For any one else having this issue (if you had put offline_access permission and later removed) follow the steps:
Go to your facebook profile setting and remove your app.
and then do login again.
Give permission to your app again.
Alternately you can do this:
Go to your facebook profile setting > Apps > Your_App and remove "Access my data any time" permission.
Save changes made.
Re-run Your_App(i.e. with no offline_access permission now).
Have you mentioned Key Hash in the app that you created on facebook? If not, create a valid one and mention it. This usually occurs because of the new update features of facebook, However, older versions of facebook work well each time. You can check this by uninstalling updates on your facebook app, and run your code. It still works fine. Learn more from here
Related
I'm using Facebook SDK v4.6
I'm trying to setup a GraphAPI request class, it will communicate to Facebook Graph API if AccessToken is available. If not, it will pass an error to my Auth class which will initiate the login process
I'm using the code below to start the login process
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile, user_photos, user_videos"));
However, the callback onCancel is always triggered whenever I do so, resulting to my application not being able to go through the Graph API process
I'm using a Facebook account which is an administrator for the Facebook app. Also the permissions user_photos and user_videos are already approved in Facebook side, so I don't think that's the problem.
Has anyone experienced the same problem?
I've been trying to look here for solution but majority of what I see is to call logout first before logging-in, but is that even correct?
I tried it on device without Facebook app installed, it repeatedly prompt the login dialog even though the user already logged-in previously (i concluded it's to be expected since we logged-out, but I wouldn't want user to repeatedly log-in after access token is expired) or is there no other way?
First make sure that,
App Id integrated with you app and App Id in Dashboard are the same or not.
Facebook user you are trying to login is a developer of your app.
(Because some permissions like 'publish_actions' will work with
developer account only not with the test user.)
Login function and Graph request should be called with main thread
of your app.
These are the issues i have faced. Still if you can't solve the issue , go through Facebook documentation once again.
I am using parse.com's Android API and have added Facebook/Twitter login support. This is working fine.
The tricky part appears to be logging out.
If I log in to my app using Twitter:
ParseTwitterUtils.logIn(UserLoginActivity.this, twitterLoginCallback);
Or using Facebook:
ParseFacebookUtils.logInWithReadPermissionsInBackground(UserLoginActivity.this, null, facebookLoginCallback);
I am prompted in a web dialog to enter my twitter credentials and then allow or deny access to my app. Once I allow it, I am able to log in successfulyl and I have access to my screen name. All is well!
When I try to log out of my ParseUser, I do get logged out. However, if I click either the Facebook or Twitter login button again, I am pre-authenticated as my previous account, I can't switch accounts.
I have tried:
Checking Chrome and Browser and neither are logged in to Twitter.
Logging out of the native Twitter/Facebook app
My login logic started as simply:
ParseUser.logOut();
For Twitter I have tried
Uninstalling my application - This does fix it but is not an ideal solution.
Not calling Parse.enableLocalDatastore(this); in my Application as suggested here: https://stackoverflow.com/a/26338326/494356
Unlinking the Twitter account as suggested here: https://stackoverflow.com/a/34052718/494356. This also has the bad side effect of creating a new ParseUser each time (but still for the same Twitter account)
I have tried changing permissions from 'Read Only` to 'Read and Write' as suggested here https://stackoverflow.com/a/27714159/494356. (Why this would matter doesn't really make sense to me anyway)
I have tried setting the AuthToken to null
ParseTwitterUtils.getTwitter().setAuthToken(null);
ParseTwitterUtils.getTwitter().setAuthTokenSecret(null);
For Facebook I have tried
Uninstalling my application - This does not solve the problem.
Using the Facebook SDK Logout Features:
AccessToken.setCurrentAccessToken(null);
Profile.setCurrentProfile(null);
LoginManager.getInstance().logOut();
There used to be a Session.closeAndClearTokenInformation() as suggested here. But Facebook has Deprecated the Session class and it is no longer in the SDK.
Unlinking the Facebook account as suggested here. Again this causes duplicate ParseUsers and I am still able to log in using the saved credentials.
I would really appreciate any answers or suggestions. Even if you can only answer for either Twitter or Facebook but not both I would still love to hear it.
In our App the login/logout process works fine for Facebook, E-Mail and even an own build google login. I can tell you the differences I see on the first look and maybe one of it does the trick for you.
First of all we do not work with the ParseUser instance directly in our code, but have a MyUser class that extends ParseUser.
Second of all the login logic is encapsulated in a background service and not called directly in our Activity. That probably won't fix the problem. But in the background service we also cache the MyUser instance, retrieve it if we need it and use that instance to logout the user (MyUser.logOut()). And it is set to null after the logout.
Last but not least: are you running the latest versions of the Parse SDK?
I am adding Facebook login to my app so to get permission to post photos for users. Having created the code, I now want to test that it works. So naturally I am using my own Facebook again to see that the system works. The first time I went through, I found some stuff I didn't like. So I made the changes. Now that I want to test again using my Facebook again, when I login, Facebook keeps telling me that I already gave the app permission. I tried uninstalling the app and then re-install, just in case it was caching locally. But that didn't help. So my question is: how do I get to reuse my account to login and request the permissions again? I hope the question is clear. If not, please ask for clarification.
I am experiencing this problem with android. But I am guessing it's similar for iOS, so I use both tags.
Open the following page in your browser: https://www.facebook.com/settings?tab=applications
Your App should be in that list, just remove it to test the authorization again.
I've installed an Android application. The first time I ran it
an OAuth2 window showed up asking me whether I wanted to grant
the application access to some scope within my user account.
However now I've gone to https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=en
and revoked access, but my application still runs normally without asking me the
question of whether to allow it access to my account or not.
The application is the sample Auth activity that comes with Google Play extras.
What can I do to get the application to display the question in a popup window again?
I've tried uninstalling and reinstalling but I cannot get that window back and I need
it for testing purposes.
Thanks.
Try to programmatically revoke the token by making a request to - https://accounts.google.com/o/oauth2/revoke and include the token as a parameter. Something like this ::
curl https://accounts.google.com/o/oauth2/revoke?token={token}
The token can be an access token or a refresh token. If the token is an access token and it has a corresponding refresh token, the refresh token will also be revoked.
If the revocation is successfully processed, then the status code of
the response is 200. For error conditions, a status code 400 is
returned along with an error code.
The error code will give you an idea if the revocation was successful or not.
I am using Simple example from the Facebook SDK just to get the user email, name, gender, facebookID to login to my server.
I am getting this Error:
yourApp is misconfigured for Facebook login. Press Okay to leave application without facebook login
This only occurs when i already have facebook app installed on my device. I tried uninstalling the facebook app, then i get correct details.
My application on facebook is configured as:
where am i doing wrong?
in place of Class Name i am giving the 1st Activity in my app, what exactly should i give here?
Thank You
even I had faced the same problem. It happens if you are using wrong version of openssl. I suggest you to use
openssl_0.9.0e_win32 version and enable log (make it TRUE), later you get new key hash. Use the new one, problem will be solved! :)