Giter Site home page Giter Site logo

Comments (16)

bgold avatar bgold commented on March 29, 2024

You can use an access_token with the old REST API as well as the new Graph API, so there's no need for a session_key.

from facebook-android-sdk.

demianalonso avatar demianalonso commented on March 29, 2024

I had the same problem and when I dealt with it it didn't appear to work the access_token as the session_key (perhaps it is working now I just cannot test it right now) but I found that you can get the session key by hooking into the FbDialog.FbWebViewClient.onPageStarted event. When the URL contains a /authorize_success then the session key is being passed in the query string.
It is then easy to retrieve it by doing:

Uri uri = Uri.parse(url);
JSONObject session = new JSONObject(uri.getQueryParameter("session"));
String sessionKey = session.getString("session_key");

I actually didn't add that directly in the onPageStarted method but delegated on the DialogListener with a new event I created.

But if the access_token works as a session_key then it is much easier and cleaner. Otherwise I can provide the modifications I made if they are useful or someone needs them

from facebook-android-sdk.

PaulFake avatar PaulFake commented on March 29, 2024

I am currently using demianalonso's workaround, but I'd like to request official support for session_keys. It would be quite a bit of trouble for my client to rework his entire API to use access_tokens instead...

from facebook-android-sdk.

lshepard avatar lshepard commented on March 29, 2024

Demian- that workaround will break in the near future when we refactor the auth flow to remove that redirect. If you have any deployed apps they will break too.

Paulfake - you have two choices. You can switch to use access token (generally simpler than sessions), or you can leave your code as is. The switch should not be very extensive, even if you are using the API in lots of places.

from facebook-android-sdk.

demianalonso avatar demianalonso commented on March 29, 2024

Hi lshepard, thanks for the reply. We tried to use the access token instead of the session key and they doesn't seem to be interchangeable.

I must noticed that my scenario might not be the most trivial one. We have an android application which relies on a server application which performs some operations. But the server is implemented using the REST API where as the client is using the Graph API, and that's why we needed to fetch the session_key so the user can log in using the Graph API but the server can still work with the older API.

I do understand that eventually the server should be migrated to use the Graph API but we were trying to ease the transition by migrating each part separatedly.

Is there an official way to do this or it is something meant to be a workaround?

Thanks for all the help.

from facebook-android-sdk.

turbofrank avatar turbofrank commented on March 29, 2024

The Auth Keys do not work in the case of XMPP Chat integration with facebook connect. I have migrated my entire app over to the graph API and now this has broken chat!! ARGGHHH!!

from facebook-android-sdk.

yeliaz avatar yeliaz commented on March 29, 2024

Looks like the patch is no longer functional and since yesterday, so the app cannot connect to the XMPP chat stream anymore
since it cannot extract the session key and secret from the authorize_success part. They are no longer there :-(
Can the Jabber endpoint accept an OAuth 2.0 access token?
What is the official way to access the XMPP stream?

Thanks

from facebook-android-sdk.

wildbeatcommunication avatar wildbeatcommunication commented on March 29, 2024

Why has this been closed if there is not solution to it? For us who want to connect to XMPP chat there is no way to do it without a session key.

Can this be incorporated into the SDK anyway? For example having the REST API included like the iOS SDK.

Currently the only way to do it would be to use fbconnect-android which has a limitless amount of problems.

Having the REST API added would be a godsend.

Thanks

from facebook-android-sdk.

hades-6 avatar hades-6 commented on March 29, 2024

Could someone please be kind enough to add a method to get the session key. I'm trying to integrate xmpp chat into my application.

Please help. :)

from facebook-android-sdk.

rachana1101 avatar rachana1101 commented on March 29, 2024

Same here, Can any one give the code that implements demianalonso solution. I will be very thankful.

from facebook-android-sdk.

rachana1101 avatar rachana1101 commented on March 29, 2024

I tried to get the information as mentioned but I am getting null pointer on
uri.getQueryParameter("session") please help

from facebook-android-sdk.

hades-6 avatar hades-6 commented on March 29, 2024

It doesn't work anymore.

from facebook-android-sdk.

rachana1101 avatar rachana1101 commented on March 29, 2024

:( so how will I get session_key, or i have to use FBConnet ???

from facebook-android-sdk.

hades-6 avatar hades-6 commented on March 29, 2024

CodeCarpet's FBConnect API

try his code :) I'm not sure if it works, I'm gonna try it today and see.

from facebook-android-sdk.

pawanm avatar pawanm commented on March 29, 2024

When using facebook android sdk with SingleSignOn (SSO), the access token format actually changed.
Instead of getting traditional auth token which contains userid & session key as a part of authToken
now we get a different format of authToken

As Facebook Devs are still in process to support there rest apis with newly formated access token
meanwhile we can disable the SSO on android facebook sdk by changing DEFAULT_AUTH_ACTIVITY_CODE to -1 from 32665 (in Facebook.java)
This will invoke Traditional dialouge for granting acess token and in return you'll get access token which will contain session key in it.

from facebook-android-sdk.

pawanm avatar pawanm commented on March 29, 2024

Those who are looking for generating secure session key you need to add your own method in Facebook.java like

public String getSessionSecret(String accessToken) throws MalformedURLException, IOException
{
Bundle b = new Bundle();
b.putString("method", "auth.promoteSession");
b.putString("access_token", accessToken);
b.putString("session_key_only", "true");
String response = request(b);
return response;
}

from facebook-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.