[RESOLVED] Facebook Key Hashes no longer required for Android?

I’m porting some of my ios apps to android.

I entered “1234” as hash key as adviced in corona tutorial, hoping to get my key like this in the logs:

D/Facebook-authorize(17378): Login failed: invalid\_key:Android key mismatch. Your key "JGn9F2vDQ/w6hexLxdefCUpxYIA" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

But I got no error, and I got a valid token managing to post on the wall.

Any idea why this happened? (I didn’t have the application authorized prior)

I suspect they are still required, though I don’t know why you were able to work.  Interesting.  I’d make it match just to be safe. 

The thing is that I can’t get the hash key in the logs. It all works without any problems. Might be some temporary bug or something.

I just generated the key using the console in the end, just to be safe.

They key you need to put on Facebook’s developer portal is:  JGn9F2vDQ/w6hexLxdefCUpxYIA

The key it’s looking for is what it prints in the log.

The sniped I posted in my first post is an example from corona tutorials pages.

I’m not able to get that key in the logs.

I made more tests and it seems that the hash doesn’t matter when all the authentication happens with the native sdk within my app.

When I install the native Facebook application, everything breaks. And no has key is being output. I made a hashkey using both my keystore password and the password “android”.

I made all of this on mac. I’m gonna try on pc because I read somewhere that there’s a problem with sha1 on mac(?).

I’ll get back with my results.

Ps: I’m using last daily build 1161 and testing on Samsung Galaxy S3.

After spending many hours debugging this problem here’s what I found:

  • Everything works fine if there’s no authentication outside my app (either the user doesn’t have native Facebook app, or my app is build with corona version before updating to Facebook SDK 3.0.1)

  • The steps from here (http://docs.coronalabs.com/guide/social/setupFacebook/index.html#app-integration) can’t be reproduced anymore. The documentation is outdated from before the update to 3.0.1. So there’s no way to see in the console the hash. So…

  • I generated the hash keys on both Mac and Windows (tried latest 2 versions of openssl). Still nothing. (From my keystore, I didn’t use the debug one as most do and fail.)

  • I get this event even though I accept the permissions of the app:

    type = session name = fbconnect phase = loginCancelled isError = false response =

  • From my research the problem is the invalid hash key, and noone seems to be able to generate it properly. They all used some code to make Facebook output the expected key.

So is there anyone having an Android app with Facebook integration that used a Corona build higher than 2013.1141 ?

 

@beckslash, I generated my FB key hash for my Android app using Terminal app on Mac not so long ago with the following command (where my app’s keystore is myapp.keystore and alias is myappalias):

keytool -exportcert -alias myappalias -keystore myapp.keystore | openssl sha1 -binary | openssl base64

I added it to my app’s page in FB Developer page.  I’m using daily build 1158 (and plan on fetching a new one early next week.)  So far, I haven’t seen problem with FB integration in my app on Android device.  I wonder what might be causing you issues…

Naomi

@Naomi

I used the same command. And entered both my keystore password and a wrong one (it seems that that command only generates two hashes).

What device did you test on? I tested on Samsung Galaxy S3. I remember reading somewhere that on htc there’s no problem.

Also did you test with native Facebook app installed on the device?

@beckslash, my app’s keystore and alias use same password.  I generated single key hash for each of my app.  I tested my app on Nexus 7, Nexus 10 and Samsung Galaxy SIII.  They are working as expected.

Naomi

Interesting. I tested with build 1158, still doesn’t work.

I noticed something weird. My Facebook app name is different than the Android app name. When I’m prompted it shows the android app name instead of the facebook name:

![6268_160210720829703_2007388777_n.jpg?oh](https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/v/6268_160210720829703_2007388777_n.jpg?oh=ba0239a54f6a443a49c4cc05b2c7b036&oe=51E5B1BB& gda =1374017708_5576737627f8fce6a10ae350cc55d08d)

And the native permission dialogue looks a bit weird…just a regular alert hmm. Is it the same on your device?

That sounds odd.  My FB app name is the same as my Android app name.  And when I’m prompted it shows the FB native permission dialogue, not the regular alert.  It seems like there’s something really odd going on with your app?  Something not right with FB app setup at the FB Dev page, or something odd with your device build.  

Are you using the android package name and its unique keystore (that pairs with FB key hash) when generating the device build?  

Naomi

Yep. Checked a thousand of times and they are right.

This is what I get from the logcat:

W/fb4a(:\<default\>):BlueServiceQueue(12302): Exception during service W/fb4a(:\<default\>):BlueServiceQueue(12302): com.facebook.http.protocol.ApiException: The proxied app is not already installed. W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:78) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:107) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:291) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:266) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:27) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:157) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:366) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:259) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:245) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:51) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:191) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.FutureTask.run(FutureTask.java:137) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.common.executors.HandlerExecutorServiceImpl$ListenableScheduledFuture.run(HandlerExecutorServiceImpl.java:268) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Handler.handleCallback(Handler.java:615) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Handler.dispatchMessage(Handler.java:92) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Looper.loop(Looper.java:137) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.HandlerThread.run(HandlerThread.java:60)

If I uninstall the native Facebook app from the device I get the FB native dialogue too. But with it on the device I get that. After I click ok I get this:

W/fb4a(:\<default\>):BlueServiceQueue(12302): Exception during service W/fb4a(:\<default\>):BlueServiceQueue(12302): com.facebook.http.protocol.ApiException: The app must ask for a basic\_info permission at install time. W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:78) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:107) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:291) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:266) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:27) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:157) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:366) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:259) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:245) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:51) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:191) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) W/fb4a(:\<default\>):BlueServiceQueue(12302): at java.util.concurrent.FutureTask.run(FutureTask.java:137) W/fb4a(:\<default\>):BlueServiceQueue(12302): at com.facebook.common.executors.HandlerExecutorServiceImpl$ListenableScheduledFuture.run(HandlerExecutorServiceImpl.java:268) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Handler.handleCallback(Handler.java:615) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Handler.dispatchMessage(Handler.java:92) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.Looper.loop(Looper.java:137) W/fb4a(:\<default\>):BlueServiceQueue(12302): at android.os.HandlerThread.run(HandlerThread.java:60) W/fb4a(:\<default\>):GDPDialog(12302): Failed to send W/fb4a(:\<default\>):GDPDialog(12302): com.facebook.fbservice.service.ServiceException: API\_ERROR: API\_ERROR W/fb4a(:\<default\>):GDPDialog(12302): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:637) W/fb4a(:\<default\>):GDPDialog(12302): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:46) W/fb4a(:\<default\>):GDPDialog(12302): at com.facebook.fbservice.ops.BlueServiceOperation$2.run(BlueServiceOperation.java:602) W/fb4a(:\<default\>):GDPDialog(12302): at android.os.Handler.handleCallback(Handler.java:615) W/fb4a(:\<default\>):GDPDialog(12302): at android.os.Handler.dispatchMessage(Handler.java:92) W/fb4a(:\<default\>):GDPDialog(12302): at android.os.Looper.loop(Looper.java:137) W/fb4a(:\<default\>):GDPDialog(12302): at android.app.ActivityThread.main(ActivityThread.java:4898) W/fb4a(:\<default\>):GDPDialog(12302): at java.lang.reflect.Method.invokeNative(Native Method) W/fb4a(:\<default\>):GDPDialog(12302): at java.lang.reflect.Method.invoke(Method.java:511) W/fb4a(:\<default\>):GDPDialog(12302): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) W/fb4a(:\<default\>):GDPDialog(12302): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) W/fb4a(:\<default\>):GDPDialog(12302): at dalvik.system.NativeStart.main(Native Method)

Strange.  I have no clue why you are getting this error…

I’m on Mac and using Corona daily build 1158, and all is working correctly on Android devices that I tested so far.  You might want to google the error and see if anything comes up?  If you are getting the error, I’m sure there are other devs who’ve dealt with the same issue sometime somewhere.

And… if you are 100% sure nothing is wrong with your app set up in FB Dev account, I wonder if your dev environment is causing problems – possibly due to your dev environment issue (if any), it’s not generating hash key properly?  

Beyond that, I’m out of suggestions.

Naomi

Can you please test build the Corona SDK Facebook sample app and see if you’re having the same problems with it?

After debugging and searching for 3 days I figured it out.

Now facebook wants us to treat the reading and writing permissions separately. So you can’t mix reading and writing permissions. (By not specifying any permissions, fb still asks for basic reading permissions).

So first you have to ask for reading, then writing permissions. It doesn’t seem right to handle it this way. I’m not sure if that’s what they want to migrate to or it’s just a bug. But here’s a fix for it.

local function getPermissions(event) &nbsp;&nbsp;&nbsp; if(event.type == "session") then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; facebook.logout() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; facebook.login( fbAppID, fbListener, {"publish\_stream"}) &nbsp;&nbsp;&nbsp; end end facebook.login( fbAppID, getPermissions)

Hey, @beckslash, glad to hear you found and fixed the problem.  About “publish_stream”, it is being deprecated (by Facebook.)  You might want to replace it with “publish_actions”, which AFAIK permits the app to handle all that which “publish_stream” does plus more.

Naomi

Hey Naomi. I’m glad too, it was a terrible experience lol. Thanks for reminding me, I was using publish_actions before, but wrote publish_stream by mistake.

Our issue is solved its giving us the wrong hashkey we recreated the keystore again its working .OOPS Still there is an issue still its not asking for any app permissions and not getting posted. If i have already authorized the app then its getting posted. Here is the code what i am using . What Permissions we need to specify in the build settings??? Please share the solution.

local fbappID =“XXXXXXXX”

local function onLoginSuccess()

 – Upload ‘iheartcorona.jpg’ to current user’s account

 local attachment = {

        name = “Test?”,

    link =  “”,

    caption = “itunes/googleplay”,

    description = " TEST",

    message = " GooglePlay : "…playLink,

    picture = " ",

    actions = json.encode( { { name = “SeeMore…” ,link = "http://www.google.com" } } )

   }

    facebook.request( “me/feed”, “POST”, attachment )

    facebook.logout()

end

local function fbListener( event )

    if event.isError then

        native.showAlert( “ERROR”, event.response, { “OK” } )

    else

        if event.type == “session” and event.phase == “login” then

            – login was a success; call function

            onLoginSuccess()

        

        elseif event.type == “request” then

            – this block is executed upon successful facebook.request() call

            native.showAlert( “Success”, " Shared Successfully.", { “OK” } )

        end

    end

     return true

end

local function onFBClicked()

       facebook.login(fbappID, fbListener, { “publish_stream” } )

end

end

Any update on a Corona fix for this?  I am able to post content on IOS but Android simply does not post any type of content.

@info8888 replace this line of your code:

       facebook.login(fbappID, fbListener, { “publish_stream” } )

with:

local function getPermissions(event) if(event.type == "session") then facebook.logout() facebook.login( fbAppID, fbListener, {"publish\_actions"}) end end facebook.login( fbAppID, getPermissions)

It should work. You can read my explanation as well to understand why this works and why your code no longer works.