Trying to integrate Facebook Android SDK 4.0 via a sample app.
Questions:
How can we check if the app has been de-authorized by the user in the app dashboard. Tried using the AccessTokenTracker in the new SDK documentation, but that doesn't seems to be getting called upon when i de-authorize the app.
The AccessTokenTracker is only called when i login or change the password on the account. Is there any other class for checking the de-authorization of an app?
The sample app: https://github.com/facebook/facebook-android-sdk/blob/b384c0655fe96db71229bfdcb981a522f3f1e675/samples/Scrumptious/src/com/facebook/scrumptious/MainActivity.java
Where exactly is the AccessToken stored in our app?
The documentation on the developer.facebook is real poor as of now.
I only want to use the SDK. I don't intend to use the Graph API along with that.
Any ideas is appreciated.
Thanks!
1) You won't get a call on the client when the user de-auths your app. What will happen is when you do a call, it will fail. The GraphResponse's getError will be not null. In this case, the FacebookRequestError's category is LOGIN_RECOVERABLE, as you need to take the user to the login flow again. You can call one of these methods to start that process with the response you received: https://github.com/facebook/facebook-android-sdk/blob/b384c0655fe96db71229bfdcb981a522f3f1e675/facebook/src/com/facebook/login/LoginManager.java#L96-L115
2) The access token is stored in your application's shared preferences under the key com.facebook.AccessTokenManager.CachedAccessToken
Related
I have an Android app, which the user can link to Spotify, with :
AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);
The problem is that I want the user to change his Spotify account so I want to logout the user from Spotify to log with another account. But the data of the connection are saved in the cache and when I use this line again :
"AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);", it does not show the connection dialog because the user is already connected.
In the doc, it says :
"To log out and clear all stored tokens, use the AuthenticationClient#clearCookies method. Both Spotify and Facebook tokens will be removed."
But the method clearCookies does not exist anymore. What can I do to logout the user and allow him to connect on another account ?
I've searched on the net and seems that this code
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, type, redirectUri)
.setShowDialog(true)
.setScopes(scopes).build();
took from this post it's your only choice to try to logout a user.
I can't test it, so you should try it yourself and see if works.
The documentation on the Spotify Android SDK is outdated and is not reflecting the new Spotify auth library on GitHub.
Spotify's Android SDK documentation is definitely outdated. My observation is that when you call
AuthorizationClient.clearCookies(context)
directly before starting Spotify's auth activity, it just works fine. But if you call it once and then expect that the user is logged out, when you start the activity later in the future, cached credentials keep messing around.
I do not prefer
builder.setScopes(arrayOf("")).setShowDialog(false).build()
as it shows you a "not you? Click to log out" option. So basically you need to log out on the Spotify UI, cannot do it from code.
In my case, the application saves the logged in user's email (I need that to show on the UI, anyway). When I want to log the user out programmatically, I just delete the saved email from the app and call
clearCookies()
when I start Spotify's Activity if the variable is empty.
A bit late, but you can use this AuthorizationClient.clearCookies(this) as
AuthenticationClient no longer exists
I have folowing scenario.
My client (local tv publisher) publishes some article and embeds tweet in it. ID of embeded tweet is sent through api to android application.
On android side i have integrated Fabric/TwitterKit and by following steps on twitter developers page i managed to show tweet in my android app on (i admit) easy way (Show tweet exp).
Now i have published application to Alpha and noticed one "little" problem :-). TwitterKit was using my local twitter account to authenticate and to show tweets. If you dont have Twitter application installed or signed out of it, my show tweet functionality wont work..
This is TwitterLogin explanation for obtaining TwitterKit auth token:
"When attempting to obtain an authentication token, the Kit will use the locally installed Twitter app to offer a single sign-on experience. If the Kit is unable to access the authentication token through the Twitter app, it falls back to using a web view to finish the OAuth process.
The simplest way to authenticate a user is using TwitterLoginButton, inside your layout..."
What i want is to simply show content of tweet by given tweetID. No sending tweets, or any other action with it. Just show data from given url. Is it possible without authentication, or what should i do now, so that current implementation works without user authentication (or with some non-single-signon-inside-app authentication)
Thank you.
UPDATE 1:
I have created MyApp extends Application class, and placed code below inside onCreate method. In application tag inside AndroidManifest file, added line:
AndroidManifest.xml
android:name=".MyApp"
onCreate:
TwitterAuthConfig authConfig =
new TwitterAuthConfig(DeveloperKey.TWITTER_CONSUMER_KEY, DeveloperKey.TWITTER_CONSUMER_SECRET_KEY);
Fabric.with(this, new TwitterCore(authConfig),
new TweetUi());
It works so far, but i am not sure if this implementations is valid.
DeveloperKey.TWITTER_CONSUMER_KEY and DeveloperKey.TWITTER_CONSUMER_SECRET_KEY are static values obtained from application created at apps.twitter.com.
You need to use Application Only authentication.
That will generate a set of keys which can be used by the application. It won't be able to post messages to Twitter (because no user is associated with it) but you will be able to read Tweets.
If you build the keys into the app, your user won't have to sign in.
All the documentation is at https://dev.twitter.com/oauth/application-only
First of all I'm sure that my fb app id is valid because users can log in my Android app using facebook credentials until some days ago (I think it's before Feb break change).
Recently new users cannot log in my Android app using facebook any more because facebook keep saying that my fb app invalid (Error is: Invalid application fb-app-id) BUT old users who already authorized my Android app for accessing their info can still log in using facebook. (Old users can still login to my app using facebook credentials but new users cannot)
Does anyone know why this happen to my facebook app and how to fix it?
Edit: When access to https://graph.facebook.com/facebook-app-id I get this error
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
Thanks you.
If you're sure the app is not in sandbox mode (which was gema.megantara's answer), and hasn't been deleted for policy reasons by Facebook the only explanation I can think of is that you've restricted the app demographically (i.e by country or age)
If that's the case the API won't return the app's details unless you make the API call using a user access token for a user who meets whatever restrictions you've applied, and users who don't meet the requirements won't be able to use the app.
If that's what you've done, you can remove the restrictions via the API (via the restrictions field of the Application object or in the ''Advanced'' tab in the app settings in the App Dashboard
If using the frontend interface to change the settings, it's the ''App Restrictions'' field you want to edit, screenshot attached
Basically the same solution as the accepted answer, just updated for the latest FB developer site has been updated so you need do this:
Apps->Your App
Status+Review
Do you want to make this app and all its live features available to the general public? -> Yes
Usually if you get error like that when visit https://graph.facebook.com/523132271032907 is because the sandbox mode is on. Have you try to reset the secret key ?
I think, this is because FB does not check whether application id is valid when the user has already logged in. It likely assumes that if the check passed, the id is valid. Apparently, locking out the users after making the app id invalid has never been a design goal.
try replacing:
<string name="facebook_app_id">CHANGE-ME</string>
with:
<string name="facebook_application_id">CHANGE-ME</string>
I want to read my friends posts (feeds?, all posts but for a specific user only) from his user wall.
I need all (posts, feeds, statuses) that i see when i look at his page directly from the website.
I use the android sdk and i tried the graph api and rest method.
My app is registered and i have logged in facebook to get the access token (permission: read_stream)
but i dont get that infos that want to.
Please help.
Thx.
How about testing your Graph API call in the Graph API Explorer?
https://developers.facebook.com/tools/explorer/
In my case, I could get my first 10 friends' feed (wall) with the url https://graph.facebook.com/me?fields=friends.limit(10).fields(feed)
Note that I used field expansion of the Graph API.
http://developers.facebook.com/docs/reference/api/field_expansion/
You need them to actually use your app and grant full permissions via the graph API.
You cannot simply 'grab a friends wall'. You must do that via your app and it needs the permissions to do so from the user in question.
After implementation of twitter in my app Now i try to implement Facebook for my app, and I found Facebook SDK for android
I use that code for login, but problem is that I want to publish a msg on a buttons click without opening web-view. I found few links on this but no one works for me.
I exactly want that same thing
How to post on facebook wall using Facebook android SDK, without opening dialog box
I use the answer for but it five following error...Even I have allow application to use my information.
Key description expected byte[] but value was a java.lang.String. The default value was returned.
01-24 10:37:33.567: DEBUG/Tests(479): got response: {"error":{"type":"OAuthException","message":"(#200) The user hasn't authorized the application to perform this action"}}
Use the Android SDK and make sure to request the publish_stream permission.
use this SDK defenately heplful to u
https://github.com/facebook/facebook-android-sdk
You need an auth token and use it with Graph API.
You can get the token via mFacebook.getAccessToken() method.
Assuming mFacebook is an authenticated Facebook instance (via authorize method)
You should have requested permission"message" when you called authorize on the Facebook object.
Regards stéphane