Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by JustAnotherDude · Jan 05, 2014 at 05:40 PM · androidfacebook

Using Facebook API with android, says login is cancelled by Player.

I'm trying to follow this example : https://developers.facebook.com/docs/unity/getting-started/android/

I am using Unity 4.3.1f1.

ADT adt-bundle-windows-x86_64-20131030

Facebook unity API 4.3.6

I generated my debug keystore using :

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Rafael.android\debug.keystore" | openssl sha1 -binary | openssl base64

Which worked OK, it gave me a proper key hash, on the Facebook settings, it shows the same keyhash, on the android build settings I selected that same debug.keystore and entered the proper password and also populated the app page on facebook with everything correctly, the package name, the class, and the key hash are all there.

However when running the example "InteractiveConsole" scene on my android the init works nicely but when I click login, it asks for permissions and I press OK, and it then says that "login was cancelled by the Player".

I am at a complete loss on why that would happen, any ideas ?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · May 05, 2014 at 02:44 PM 0
Share

this is Amazing. Rafael == genius

This is the only crossplatform solution, I believe.....

You saved the day, Rafael. Incredible idea.

alt text

6 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by JustAnotherDude · Jan 05, 2014 at 06:57 PM

So answering my own question, turns out the key hash was wrong, I modified the facebook API file AndroidFacebook.cs and made it log whatever key hash it was using by changing this method :

         public void OnLoginComplete(string message)
         {
             var parameters = (Dictionary<string, object>)MiniJSON.Json.Deserialize(message);
 
             if (parameters.ContainsKey("user_id"))
             {
                 isLoggedIn = true;
                 userId = (string)parameters["user_id"];
                 accessToken = (string)parameters["access_token"];
             }
 
             if (parameters.ContainsKey("key_hash"))
             {
                 keyHash = (string)parameters["key_hash"];
                 Debug.Log("proper keyhash : " + keyHash);
             }
 
             OnAuthResponse(new FBResult(message));
         }


And the logged keyhash was different from what every other method was giving me, including the API own informed key, I added the proper key to the facebook page it everything is OK now.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sriram90 · Jan 30, 2014 at 11:06 AM 0
Share

Hey @RafaelF82 , Good to see this post. Am too running through this same error, but i couldn't able to fix it. I have changed the code how you mentioned above, but it's not entering into the

 if (parameters.Contains$$anonymous$$ey("key_hash"))
  {
 }

so i couldnt able to get the proper key hash value. I created a $$anonymous$$eyhash through console with alias and keystore and pasted it into the application settings on facebook. no luck. can please help to figure out ?

I/Unity (26072): LoginCallBack : UI$$anonymous$$anager Text :{"is_logged_in":false,"user_id":"","access_token":""} Error : I/Unity (26072): I/Unity (26072): (Filename: ./Runtime/ExportGenerated/Android$$anonymous$$anaged/UnityEngineDebug.cpp Line: 54) I/Unity (26072): LoginCallBack : Login cancelled by Player : I/Unity (26072): I/Unity (26072): (Filename: ./Runtime/ExportGenerated/Android$$anonymous$$anaged/UnityEngineDebug.cpp Line: 54)

avatar image Fattie · May 05, 2014 at 02:47 PM 0
Share

Hi @sriram90 - it works perfectly; you have to run it ON A DEVICE; ie build to your device and actually connect over wifi to FB. You will have to FIND A WAY to display the information on your device screen; for example you must have some sort of "user alert" system; use that. Or just literally email it to yourself, or bring it up in a text field -- anything you can to display it on the screen of your device!

avatar image Peeling · Jun 06, 2014 at 10:13 AM 1
Share

NB: DO NOT REPLACE THE FUNCTION WITH THE ONE ABOVE ANY $$anonymous$$OR$$anonymous$$ There's extra code in the latest FB sdk that isn't in that function. Just insert the debug log line.

Seriously, do it this way, especially if you are adding FB to an existing published app. Dicking around with keystores is a fantastic way to lose the ability to update your app forever. This method worked first time (you just have to log the key out from a device).

avatar image ghulamustafa · Aug 04, 2014 at 05:53 PM 0
Share

my code does not reach to this point. I am a new indie developer. The code does not reach to the debug.log point. Any help??

avatar image shopguy · Sep 10, 2014 at 03:52 AM 0
Share

From what I can tell you no longer need this trick. When Facebook fails the actual FB UI displays this token now. The only catch in my case was that the hash FB showed didn't include a trailing equal sign.

Show more comments
avatar image
2

Answer by vfxjex · Jul 06, 2014 at 02:38 PM

to those who might need this its really useful and it works for me I just copy this instruction from this link http://answers.unity3d.com/questions/573199/debug-android-hash-key-facebook-sdk.html

so first things first,

1) Download and install OpenSSL. http://slproweb.com/products/Win32OpenSSL.html

Win32 OpenSSL v#.#.# (not Light)

OR Win64 OpenSSL v#.#.# (not Light)

2) Add the OpenSSL directory to your path.

Go to: Control Panel > System > Advanced system settings > Environment Variables

Select the Variable "Path" in the "System variables" window and click Edit.

3) Add the path to your OpenSSL bin folder to the end of the "Variable value" text. e.g. I added ";C:\Program Files\OpenSSL-Win64\bin" to the end of the value text.

Restart Unity3D.

take note do not forget to add semi-colon ";" before the C:/

4) If you get the error in FacebookSettings "Keytool not found", you need to add the JDK (Java Development Kit) bin directory to the Path variable value.

5) Follow the same steps as before, but instead of the OpenSSL bin path, add the JDK bin path. e.g. I added ";C:\Program Files\Java\jdk1.7.0_45\bin" to the end of the value text.

Restart Unity3D.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Jul 06, 2014 at 02:58 PM 0
Share

Good one - but this doesn't help on $$anonymous$$ac. Very reliable is simply to do what Rafael said, which is very easy, and then you get to see "the actual value, no matter what."

avatar image Kabe0 · Jul 06, 2014 at 04:18 PM 0
Share

$$anonymous$$y Facebook SD$$anonymous$$ fix basically gets you the proper keyhash value within unity that the actual facebook sdk uses. (So that way you don't have to try to read print logs).

avatar image NaumanH · Jan 28, 2015 at 06:52 PM 0
Share

This worked! Thanks man, thanks a lot.

avatar image JigneshKoradiya · Aug 02, 2015 at 04:57 PM 0
Share

https://youtu.be/VD9UfjnPF-I

avatar image
1

Answer by Kabe0 · May 22, 2014 at 08:23 AM

Hi guys... Sorry to revive such an old thread but I found the actual reason for the different keystore value. It is using the keystore defined in your publish settings. You have to either define the debug.keystore file there or use something like the fix i wrote for the faceboook sdk below.

Facebook SDK Fix

I just make the facebook sdk use the defined PlayerSettings.Android keystore values. Hope this helps! Cheers! (Just update to version 6.0)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · May 23, 2014 at 07:17 PM 0
Share

If only the Facebook engineers made as big an effort as you, man! thanks!

avatar image Hamza Hasan · Jul 08, 2014 at 01:30 PM 0
Share

I love you man... ($$anonymous$$abe0)...

Thank you sooooo muchhhh..........

avatar image
1

Answer by seno · Jul 09, 2014 at 07:08 AM

Good post. I would like to add one more solution for when it fails even though following all solutions posted here. If the facebook app hasn't been opened for public, then only development accounts can be log in to the facebook app. I spent about 2 hours because of this reason.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Jul 09, 2014 at 07:25 AM 0
Share

actually that's a great point and will help people!

avatar image drewnusser · Dec 17, 2014 at 05:13 AM 0
Share

Well I feel like an idiot! This was bugging me for like 2 hours before I found your solution. Went ahead and flipped the switch to make it public and now I'm golden. Thank you, seno!

avatar image
0

Answer by youest · Jul 10, 2014 at 10:55 AM

I lost a lot of time because even with the correct hashkeys on developer configuration page, the login fails as above, the problem was that the manifest is wrong, be careful with "regenerate manifest" button, it seems do not work well (at least for me). To really re-generate the manifest I had to delete the manifest file and then click on regenerate it.

I hope this can help someone...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rewarding Facebook requests 0 Answers

Facebook SDK - FB.Init throws AuthTokenNullException on Android 1 Answer

Unity Facebook apprequest notifcation opens browser instead of play store 0 Answers

Facebook SDK 3.1.2 for Unity - Trouble logging in on Android Devices 1 Answer

Can't build after importing facebok SDK 7.10.0 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges