How can I manage facebook permission in Android - android

I'm studying on an android app with using facebook api. I have two activity, first one is to select friends and second one is to send somethings friends wall . I'm getting permission in first activiy but second activity is also requires permission . How can I make first permission in second activity , too .
Is it suitable doing facebook object static?

Permissions are associated with a particular Facebook App (you pass the App ID and App Key to the Android Facebook SDK). Hence, if you use the same Facebook App details in both activities, they both will be having the same permissions.

Peace be upon you,
Acquiring friends' info requires curtain permissions. e.g.
session.requestNewReadPermissions(new NewPermissionsRequest(FacebookLogin.this, Arrays.asList("friends_birthday", ...)));
However, publishing requires different permissions. e.g.
session.requestNewPublishPermissions(new NewPermissionsRequest(FacebookLogin.this, Arrays.asList("publish_actions")));
I recommend that you ask for permissions on need basis. e.g. by adding permission request command in the implementation of a Button.

Related

Facebook Login with Read and Publish(Write) permissions

I am trying Facebook Login in Android with LoginManager class. I want read and write permissions during login only. The issue I am facing is , If I try with
LoginManager.getInstance().loginWithReadPermissions();
LoginManager.getInstance().loginWithPublishPermissions();
If Facebook App is not installed, Facebook WebView loads up, I enter credentials, I see two permissions screen (One for Read and One for write) and then again Login Screen.Which basically, creates bad user experience.
It happens because, both loginWithxxxPermissions() methods,starts a new login flow.But actually, It should not show Login Screen for already logged in user.
I am not able to find any method to pass the accessToken to let me the method know that, the new permission query is for already logged in user.
Anyone, Please help me out or suggest some other alternative, But the requirement is clear. I need Read/Write permissions without showing Login screen twice.

Check if app is de-authorized facebook android SDK 4.0

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

Set permissions using Temboo for Facebook API

I am currently developing an app where I have been using temboo to search a user on Facebook. I am able to get the basic results which do not need any additional permissions.
But for fields like education history, about_me etc, I need to include additional permissions to retrieve these fields.
Could you please let me know how to add these permissions to the temboo FQLinputsets?
Thanks!
I work at Temboo.
I would recommend using our OAuth Helper Choreos to go through the OAuth process, and request an additional set of permissions:
https://www.temboo.com/library/Library/Facebook/OAuth/
In the first step of the OAuth process, you'll run the InitializeOAuth choreo. This is where you can specify the permissions you need to request by passing a comma-separated list of permissions to the "Scope" input. You'll want to pass user_education_history,about_me along with any other permissions you'd like to request. Here's an example of the input set:
// Set inputs
initializeOAuthInputs.set_AppID("YOUR_FACEBOOK_APP_ID");
initializeOAuthInputs.set_Scope("user_education_history,about_me");
Then you can complete the OAuth process by running the FinalizeOAuth choreo. This will return an access token that should have the permission you need to retrieve those fields.
https://www.temboo.com/library/Library/Facebook/OAuth/FinalizeOAuth/
There is a video tutorial about the OAuth Choreos here:
https://www.temboo.com/videos#oauthchoreos
Hope this helps. Let us know if you have any other questions.
Cormac

SDK 3.0 reauthorizeForPublish() loses read permissions?

Using the beta 3.0 SDK on Android, I'm opening a Facebook Session with a simple session.openForRead() call with basic permissions (email).
As soon as I want to publish a message on a user's wall I'm re-authorizing the session with session.reauthorizeForPublish() including the new publish permissions (publish_actions) in the ReauthorizeRequest object.
As soon as the last request succeeded, a call to session.getPermissions() only returns the last requested permissions (publish_actions), but loses all of the previous read permissions (email).
The documentation of ReauthorizeRequest's parameter permission clearly states "additional permissions to request", so I'm currently not quite sure why the session loses all the other permissions after a request?
Many thanks,
Alex
Alex, sorry you are running into this. This is a bug in the SDK that we are working on fixing prior to the final release. In the meantime, there are a couple of workaround approaches you could try.
While the Session object's notion of its permissions is out of sync with the Facebook service, the access token associated with the Session still has those permissions and can still be used to make Graph API calls requiring any of the permissions it has been granted (unless the user has subsequently revoked any of them, of course). So if your application logic allows you to disregard the results of the Session.getPermissions() call (for instance, if your UI flow implies the user must have already granted a certain permission prior to reaching a certain step in the flow, so you can assume it is present), you can go ahead and make Graph API calls that require those permissions regardless of what getPermissions says -- real truth about what permissions are associated with the token lives in the service, not in the Session object.
If your app logic is such that you need to check whether a certain permission has been granted, unfortunately right now you may need to keep track of the permissions separately,
perhaps by declaring an ArrayList<String> somewhere that you append the new permissions to, perhaps in your Session.StatusCallback whenever the session is opened, and clear it whenever the session is closed. (You could also make a call to "me/permissions" each time the state transitions to OPENED_TOKEN_UPDATED and store the results.) This should be considered only a temporary workaround until the real fix is available. Hope this helps.

How to get a friends user wall from facebook?

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.

Categories

Resources