Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[RESOLVED] Facebook Key Hashes no longer required for Android?
Started by beckslash Jul 13 2013 02:27 AM

25 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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)



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,569 posts
  • Corona Staff

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. 



[TOPIC: post.html]
#3

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,569 posts
  • Corona Staff

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.



[TOPIC: post.html]
#5

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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.



[TOPIC: post.html]
#6

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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 ?

 



[TOPIC: post.html]
#7

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

@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


[TOPIC: post.html]
#8

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

@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?



[TOPIC: post.html]
#9

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

@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



[TOPIC: post.html]
#10

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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

 

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



[TOPIC: post.html]
#11

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

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



[TOPIC: post.html]
#12

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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)



[TOPIC: post.html]
#13

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

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



[TOPIC: post.html]
#14

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,569 posts
  • Corona Staff

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



[TOPIC: post.html]
#15

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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)
    if(event.type == "session") then
        facebook.logout()
        facebook.login( fbAppID, fbListener, {"publish_stream"})
    end
end

facebook.login( fbAppID, getPermissions)


[TOPIC: post.html]
#16

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

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



[TOPIC: post.html]
#17

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

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.



[TOPIC: post.html]
#18

info8888

[GLOBAL: userInfoPane.html]
info8888
  • Enthusiast

  • 36 posts
  • Corona SDK

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 = "[url="""][url="http://www.google.com""]http://www.google.com"[/url][/url] } } )
   }
    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


[TOPIC: post.html]
#19

rxmarccall

[GLOBAL: userInfoPane.html]
rxmarccall
  • Contributor

  • 751 posts
  • Corona SDK

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.



[TOPIC: post.html]
#20

beckslash

[GLOBAL: userInfoPane.html]
beckslash
  • Contributor

  • 113 posts
  • Corona SDK

@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.



[TOPIC: post.html]
#21

rxmarccall

[GLOBAL: userInfoPane.html]
rxmarccall
  • Contributor

  • 751 posts
  • Corona SDK

@beckslash,

Your code did not solve the Android issue for me.  Also it makes the facebook login get called twice for whatever reason.  Works on IOS, but not on Android.



[TOPIC: post.html]
#22

info8888

[GLOBAL: userInfoPane.html]
info8888
  • Enthusiast

  • 36 posts
  • Corona SDK

I Agree what rxmarccall says its asking twice the app permission. The fb issue is not solved only the thing is that its getting posted at least . The problem that still exists is when we login the fb from the app its asking for the permissions twice and for the first time its not getting posted (if you have not previously approved the app permissions in the fb). After that when You again press the share button it gets posted.  

 

       I can say its just the temporary fix for now,actual problem still remains. Thanks for the temporary fix.



[TOPIC: post.html]
#23

rxmarccall

[GLOBAL: userInfoPane.html]
rxmarccall
  • Contributor

  • 751 posts
  • Corona SDK

Yea, users are just going to be confused if they hit "post to facebook", and nothing happens until they push the button a second time, which they won't do.



[TOPIC: post.html]
#24

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,569 posts
  • Corona Staff

Well your login process should be handling the 2nd login request.  I would not tie it to a button for the users to have to hit and then hit again.  Engineering is looking into to seeing if this is something that we can solve.  No promises. 

 

Gotta love Facebook.



[TOPIC: post.html]
#25

rxmarccall

[GLOBAL: userInfoPane.html]
rxmarccall
  • Contributor

  • 751 posts
  • Corona SDK

Yea facebook is the worst haha.  I never use it.  Hoping that it will die a terrible death sooner rather than later.  Might just leave it out of my apps, its more trouble than its worth it seems. thanks for the support as always.




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]