midworld / unity-googledrive

Google Drive for Unity3D
Apache License 2.0
121 stars 28 forks source link

Error when publishing for iOS using Unity 5.4.0b22 #11

Closed normmcgarry closed 7 years ago

normmcgarry commented 8 years ago

Error when publishing for iOS using Unity 5.4.0b22. See #12 .

Type '[Assembly-CSharp]WebViewObject' has an extra field 'token' of type 'System.String' in the player and thus can't be serialized 

Type '[Assembly-CSharp]WebViewObject' has an extra field 'cancelled' of type 'System.Boolean' in the player and thus can't be serialized

Fields serialized in Editor, class 'WebViewObject'

Fields serialized in target platform, class 'WebViewObject'
    'token' of type 'System.String'
    'cancelled' of type 'System.Boolean'
gislersoft commented 8 years ago

A Workaround is to put both fields as private then create the accessors :

  public string getToken(){
    return token;
}

public bool getCancelled(){
    return cancelled;
}

and in GoogleDriveAuthorization change to:

            while (webView.getToken() == null && !webView.getCancelled())
        yield return null;

    if (webView.getCancelled())
    {
        GameObject.Destroy(obj);

        IsAuthorized = false;

        yield return new Exception(-1, "Authorization failed.");
        yield break;
    }

It is going to compile but seems that google is not allowing more OAuth through a WebView, so this is the message that you get when you upload to your device so it is not working for iOS: iosdrive

DertyMunky commented 8 years ago

I am also getting this 403 error on iOS. Can someone please help with some suggestions on how to fix this?

normmcgarry commented 8 years ago

Yeah, Google is now requiring apps to perform sign-ins through the native iOS browser instead of a web view. I had to end up writing my own custom plugin for my project. You need to either use GTMAppAuth or Google Sign-In for iOS along with Google API Objective-C Rest Client to do the actual API requests. Those are the most recent libraries.

The oauth hook-ins on the iOS App Delegate and integration into the app's plist make the new sign-in flow a pain to implement in Unity as well. Basically, all the changes require a major rewrite of this plugin...