To avoid the need of storing secret tokens on a mobile device, Facebook
leverages the presence of the official Facebook Android application on
Android devices. The Facebook SDK allows third-party applications to use
Android intents to proxy requests for user access tokens through Facebook's
Android application, where the user is already authenticated. To retrieve a
user's access token with the Facebook SDK, the Android application identifier
of a third-party application must be registered on its Facebook application
settings page. This allows Facebook's Android application to respond to the
third-party application's access token request by verifying the application
identifier in the intent to the one officially registered online. Only the
application identifer is needed and no secret key is compromised since it
is retrieved at runtime. This technique relies on the robustness of Android
since the source of the Android intent is assumed not to be spoofable.
Does anyone have a clearer description of this process. I've now read this extract three times and I'm none the wiser.[1] http://www.cs.columbia.edu/~nieh/pubs/sigmetrics2014_playdro...
Because you've registered this information, Facebook will only allow your app to perform actions if it not only has the correct API key but also matches the registered details. I suppose this means that if someone decompiles your app and steals your key they can't perform actions pretending to be you.
*edit I mean it's not true that the attacker can't impersonate your app. Your description of how it works looks right on to me. :)
https://github.com/facebook/facebook-android-sdk/blob/master...
The process is described here: https://developers.facebook.com/docs/android/getting-started...
The Facebook app for Android is closed source; however, the Facebook Android SDK seems to verify requests from the Facebook app in a similar way: https://github.com/facebook/facebook-android-sdk/blob/master...
I imagine that it works like that the other way around as well: Check whether the code signature of the Intent's sender matches the app developer certificate.
There are suggestions in comments here that you hide your third party API keys in your own backend server, and your app queries for the API keys and then makes the call from the client using the temporary downloaded keys.
So how do you secure your own server's API keys? That's just a Russian doll implementation.
I can't see a valid way to access an API key using a consumer key / secret without storing them in the application.
Any suggestions?