22

I'm testing the InteractiveConsole example in Unity. I did some configurations as described in the official tutorial. After some setups I got on step 7: Run our example code.

However, I'm receiving the following errors:

Unable to verify assembly data; you must provide an authorization key when loading this assembly. UnityEngine.Security:LoadAndVerifyAssembly(Byte[]) c__Iterator1:MoveNext() (at Assets/Facebook/Scripts/FB.cs:326)

Could not securely load assembly from https://integrated-plugin-canvas-rsrc.fbsbx.com/rsrc/unity/lib/sdk_4.0/CanvasFacebook.dll UnityEngine.Debug:LogError(Object) FbDebug:Error(String) c__Iterator1:MoveNext() (at Assets/Facebook/Scripts/FB.cs:329)

Not sure what to do. Any ideas?

janisz
  • 6,292
  • 4
  • 37
  • 70
user3118059
  • 221
  • 2
  • 3
  • Which version of the Unity Editor are you on? – Brian Jew Feb 18 '14 at 19:42
  • I'm using 4.6 pro (BETA) But the problem remains in 4.3.4. – user3118059 Feb 20 '14 at 02:48
  • 3
    Unity recently updated `Security:LoadAndVerifyAssembly` to take an authorization key in Unity Editor 4.5. We are working to have that support on Facebook's end. For now the current version is only supported for Unity Editor <4.5 – Brian Jew Feb 21 '14 at 19:45
  • 2
    For now as a workaround if you want to stay with Unity Editor 4.5+, open `FB.cs` and look for `var assembly = Security.LoadAndVerify Assembly(www.bytes);` change that to: `var assembly = Security.LoadAndVerifyAssembly(www.bytes, "o+uJXoVE53pt2yC+6MNtM+S1eQ12KoaJUWOveWIZ9Q3BWQTqhcWA9mllY6HjVXSLY5E0uWEgAWGalwSf4z8c3XIfIInxSjh33N8IYCyMsrkctcj4LhPIl+EcKDgY4L2xKFqqiEi5k7z6LU3M4+RY+7LsgGL7m7Io+8F/LxoOhnoWVGCQ1uXgQ+8G4emvplGRQy7usgruhbHvMsWtd9GXhJV29gFQa3h88R5obXgxNKGXQea0Ex8dQdRS41TS7+fywh6RFsoq9sFxi+dePoW8bGBP+NxKpCxzEIk8UVRD8fZsE/Zl2FzGyIGjn5QXJuPrS+rYhLLbqfLz07Inf7LNCg==");` – Brian Jew Feb 21 '14 at 19:52
  • 2
    Can you post updated data for the 5.0.3 release? – Khakionion Mar 13 '14 at 08:42
  • 1
    Here's the newest key: `B8GvecdX0rQ47kzhCEwlrRzYKA8LKeiZxy1HI3HfnhdgUATvBwQQViji8ot44dADM55QuHk5+hwrLsoau32IDmRDQTclMSsTsIywGRo/nE5vbmRMMIECYXBFhliz+kvK0RWZ57XPxw0s7YhGnNLav0EE2QH/m+9ajlLOY+2ckxSoSEHLpotllyZLktRK+oFiDPvmzXLDUMOnwK9RFRSh2VBmoyWTZx8BYqWjqug3kAljJk/XwTYZT9Ie+HvzLO5DBSqMNYbEX03WaNfpaq9GKBF/Oz37AHelf1Es36amP1v2Aut3nmIk2xxN6zwzBXyEyw90vJ/O8suikU+8kDDbZA==` – Brian Jew Mar 26 '14 at 19:52
  • I'm getting: FormatException: Invalid character found. System.Convert.FromBase64String (System.String s) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Convert.cs:146) UnityEngine.Security.LoadAndVerifyAssembly (System.Byte[] assemblyData, System.String authorizationKey) (at C:/BuildAgent/work/aeedb04a1292f85a/Runtime/Export/Security.cs:66) FB+RemoteFacebookLoader+c__Iterator1.MoveNext () (at Assets/Facebook/Scripts/FB.cs:358) :| – arturaz May 29 '14 at 16:15
  • Ok, it seems that some utf symbols copy themselves when you copy the whole thing from SO. Copy line by line. – arturaz May 29 '14 at 16:18
  • Hi @Brain Jew could you please link to / comment how you generated that key if you have a moment? Thanks. – paulecoyote Jun 17 '14 at 03:17
  • This is the exact problem I was getting, adding the line reference on my code just for search reference, var assembly = Security.LoadAndVerifyAssembly(www.bytes); Adding the answer below like RemeR suggested solved it for me. – Mastro Jan 03 '15 at 22:31

3 Answers3

30

Instead of change the call to LoadAndVerifyAssembly as @BrianJew suggests, you simply can change the line 381 of FB.cs, where it says

#if UNITY_4_5

you should put

#if UNITY_4_5 || UNITY_4_6

Or the appropiate flag for your Unity's version. In that block the key is obtained from this URL https://integrated-plugin-canvas-rsrc.fbsbx.com/rsrc/unity/key/sdk_5.1/AuthToken.unityhash

RemeR
  • 667
  • 8
  • 20
1

Another simple fix:

Change line 411 of FB.cs to:

#if UNITY_4_5 || UNITY_EDITOR

This has been tested in version 5.2.1.

rhughes
  • 9,257
  • 11
  • 59
  • 87
1

Same thing for unity 5.1, just add || UNITY_5_1 to corresponding line in FB.cs

ryangre
  • 11
  • 1