loginCancelled while performing facebook.login()

Hello guys!

I don’t know why, although I set up my facebook app correctly, I’m getting loginCancelled error every time I try to login to facebook from my mobile app.

This is the code I use to test my facebook login:

local fbAppID = "xxxxxxxxxxxxxxx" local facebookListener = function(event) if ("session" == event.type) then first = display.newText( event.phase, 0, 100, nil, 13 ) if ("login" == event.phase) then local theMessage = "test..." facebook.request("me/feed", "POST", {message = theMessage}) end end end facebook.login(fbAppID, facebookListener, {"publish\_stream"})

Every time I test my application, _ first _ (display.newText) shows “loginCancelled” as event.phase.

This screenshot shows facebook app settings:

2i93344.png

For the last few days I’ve been trying to figure out where’s the problem, but without any success. Please help me solve this problem.

Cheers

Are you sure the hashkey is right?  Can you post the results from your device’s console log?  Does the device have the native Facebook app installed or is it using the browser to try and login?

hi, device does have facebook app installed. I got this hashkey following facebook’s tutorial about getting hashkey from cmd and it should be right.

I can’t get console log from device… So I would be glad if you can help me without it.

Why can’t you get to the console log?

And depending on the commands you executed, you may not have gotten the hash key generated correctly.  The problem with the Facebook steps is they blindly assume things about your system.  For instance, if you’re using the Debug keystore, then the one Corona uses is not the one they use in those instructions and the keyhash won’t match.    Also, if you’re using your release keystore, then you have to be in the right folder where the release keystore lives to generate the right keyhash.   Please make sure to read this blog post:

http://www.coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Pay special attention to the “Android Process” section.

I can’t get to the console log of my device because I’m not testing this application on device. I’m testing it using Bluestacks app player that has the same behaviour as mobile device.

Thank you for sharing this blog post with me. For the last 2 hours I’ve been trying to get correct Key Hash and to make my app work. Unfortunately, again without success, even I created own keystore and alias and build my app using that keystore and keyalias.

You can see my cmd inputs here:

 

d:\Program Files (x86)\Corona Labs\Corona SDK\Resources\>"d:\program files (x86)\ java\jre6\bin\keytool.exe" -genkey -v -keystore eakeystore.keystore -alias alias name -keyalg RSA -validity 999999 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: xxxxx xxxxx What is the name of your organizational unit? [Unknown]: xxxxx What is the name of your organization? [Unknown]: xxxxx What is the name of your City or Locality? [Unknown]: xxxxx What is the name of your State or Province? [Unknown]: xxxxx What is the two-letter country code for this unit? [Unknown]: XX Is CN=xxxxx xxxxx, OU=xxxxx, O=xxxxx, L=xxxxx, ST=xxxxx, C=XX cor rect? [no]: yes Generating 1.024 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 999.999 days for: CN=xxxxx xxxxx, OU=xxxxx, O=xxxxx, L=xxxxx, ST=xxxxx , C=XX Enter key password for \<aliasname\> (RETURN if same as keystore password): [Storing eakeystore.keystore] d:\Program Files (x86)\Corona Labs\Corona SDK\Resources\>"d:\program files (x86)\ java\jre6\bin\keytool.exe" -exportcert -alias aliasname -keystore eakeysto re.keystore | openssl.exe sha1 -binary | openssl.exe base64 Enter keystore password: android 1Jbl2NBIVgCY

You can see that I got keyhash but for some reason I still cannot login to my facebook account. I really don’t know what’s wrong and why I keep failing.

Thanks for your help and quick replies.

We don’t support running apps on Bluestacks.  There should be a way to get a log from them.  I know in the past, there have been issues with trying to run on Bluestacks.   There is a group on facebook of people who’ve offered to beta test things.  They are call Corona subscribers and can get the logs for you.

https://www.facebook.com/groups/102481146589254/

One other thing, since you created a new keystore, are you building your app in Corona against that new keystore or are you using the debug keystore or some other keystore when you got o build the APK?  

I use that new keystore and keyalias when I build the APK. I tried this new version of APK on mobile device too and result was the same: “loginCancelled”. As I don’t own Android mobile device, it’s pretty hard to me to test apps on device.

thanks for suggestion. 
 

What else could cause the problem? Am I doing something wrong while creating keystore or keyalias?

Thanks to one developer (Phil Smith), the problem is now solved. I don’t know why, but we got different hash key genereted on Mac. Key we got was the working one and now everything works well.

I’m a little confused, but happy because it works.

thanks for your time, Rob

Are you sure the hashkey is right?  Can you post the results from your device’s console log?  Does the device have the native Facebook app installed or is it using the browser to try and login?

hi, device does have facebook app installed. I got this hashkey following facebook’s tutorial about getting hashkey from cmd and it should be right.

I can’t get console log from device… So I would be glad if you can help me without it.

Why can’t you get to the console log?

And depending on the commands you executed, you may not have gotten the hash key generated correctly.  The problem with the Facebook steps is they blindly assume things about your system.  For instance, if you’re using the Debug keystore, then the one Corona uses is not the one they use in those instructions and the keyhash won’t match.    Also, if you’re using your release keystore, then you have to be in the right folder where the release keystore lives to generate the right keyhash.   Please make sure to read this blog post:

http://www.coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Pay special attention to the “Android Process” section.

I can’t get to the console log of my device because I’m not testing this application on device. I’m testing it using Bluestacks app player that has the same behaviour as mobile device.

Thank you for sharing this blog post with me. For the last 2 hours I’ve been trying to get correct Key Hash and to make my app work. Unfortunately, again without success, even I created own keystore and alias and build my app using that keystore and keyalias.

You can see my cmd inputs here:

 

d:\Program Files (x86)\Corona Labs\Corona SDK\Resources\>"d:\program files (x86)\ java\jre6\bin\keytool.exe" -genkey -v -keystore eakeystore.keystore -alias alias name -keyalg RSA -validity 999999 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: xxxxx xxxxx What is the name of your organizational unit? [Unknown]: xxxxx What is the name of your organization? [Unknown]: xxxxx What is the name of your City or Locality? [Unknown]: xxxxx What is the name of your State or Province? [Unknown]: xxxxx What is the two-letter country code for this unit? [Unknown]: XX Is CN=xxxxx xxxxx, OU=xxxxx, O=xxxxx, L=xxxxx, ST=xxxxx, C=XX cor rect? [no]: yes Generating 1.024 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 999.999 days for: CN=xxxxx xxxxx, OU=xxxxx, O=xxxxx, L=xxxxx, ST=xxxxx , C=XX Enter key password for \<aliasname\> (RETURN if same as keystore password): [Storing eakeystore.keystore] d:\Program Files (x86)\Corona Labs\Corona SDK\Resources\>"d:\program files (x86)\ java\jre6\bin\keytool.exe" -exportcert -alias aliasname -keystore eakeysto re.keystore | openssl.exe sha1 -binary | openssl.exe base64 Enter keystore password: android 1Jbl2NBIVgCY

You can see that I got keyhash but for some reason I still cannot login to my facebook account. I really don’t know what’s wrong and why I keep failing.

Thanks for your help and quick replies.

We don’t support running apps on Bluestacks.  There should be a way to get a log from them.  I know in the past, there have been issues with trying to run on Bluestacks.   There is a group on facebook of people who’ve offered to beta test things.  They are call Corona subscribers and can get the logs for you.

https://www.facebook.com/groups/102481146589254/

One other thing, since you created a new keystore, are you building your app in Corona against that new keystore or are you using the debug keystore or some other keystore when you got o build the APK?  

I use that new keystore and keyalias when I build the APK. I tried this new version of APK on mobile device too and result was the same: “loginCancelled”. As I don’t own Android mobile device, it’s pretty hard to me to test apps on device.

thanks for suggestion. 
 

What else could cause the problem? Am I doing something wrong while creating keystore or keyalias?

Thanks to one developer (Phil Smith), the problem is now solved. I don’t know why, but we got different hash key genereted on Mac. Key we got was the working one and now everything works well.

I’m a little confused, but happy because it works.

thanks for your time, Rob