facebook / facebook-sdk-for-unity

The facebook sdk for unity.
https://developers.facebook.com/docs/unity
Other
489 stars 256 forks source link

No permission to upload video even with publish_video permission #417

Open michelleran opened 4 years ago

michelleran commented 4 years ago

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

Goals

After logging in with the publish_video permission, upload a video to /me/videos

Expected Results

Successful video upload

Actual Results

The login is successful:

{"opened":"true","last_refresh":"1584918686","granted_permissions":["email","publish_video","user_friends","public_profile"],"callback_id":"2","declined_permissions":[],"graph_domain":"facebook","user_id":"1168026570010947","expiration_timestamp":"1590076398","access_token":"EAAQ1JKMblCABAKLe64lqTmBGnKUWcU3jMbXRmKVEyRSulxIGHsG6oy1YA2KQtL6QbZAzrRcyQJoScGd1ZB66DaVP5gZAPdjF8WLGZCd1OwniVqyMqaC6K68NDN0gQlIBz3XnyzPLW5EwEZCZBKSCyCl1LmrReZBWh4UZC7wduXf2B11drv7V69v3SujdNvrAvRLuo44CHOvMZCYODKFKYXYkaGG0ZBAm1AddmPCKJBcNj4VgZDZD","permissions":["email","publish_video","user_friends","public_profile"]}

But the upload is not:

{"error":{"message":"(#100) No permission to publish the video","type":"OAuthException","code":100,"fbtrace_id":"AWUNTlXGLLhiNtgEqnf26Gp"}}

Steps to Reproduce

  1. Initialize Facebook SDK
  2. Log in with publish_video permission (either LogInWithReadPermissions or LogInWithPublishPermissions)
  3. Use FB.API to post to /me/videos

Code Samples & Details

Please provide a code sample, as well as any additional details, to help us track down the issue. If you can provide a link to a test project that allows us to reproduce the issue, this helps us immensely in both the speed and quality of the fix.

Note: Remember to format your code for readability:

private static void Init(Action<bool> callback) {
            FB.Init(() => {
                if (FB.IsInitialized) {
                    Debug.Log("Initialized Facebook SDK");
                } else {
                    Debug.LogError("Failed to initialize Facebook SDK");
                }
                callback(FB.IsInitialized);
            });
}

public static void Login(Action<bool> callback) {
            if (!FB.IsInitialized) {
                Init(success => {
                    if (success) Login(callback);
                });
            } else {
                FB.LogInWithPublishPermissions(new List<string>() { "public_profile", "email", "user_friends", "publish_video" }, result => {
                    if (result == null) {
                        Debug.LogError("Null result");
                        callback(false);
                    } else if (result.Cancelled) {
                        Debug.LogError("Cancelled");
                        callback(false);
                    } else if (string.IsNullOrEmpty(result.RawResult)) {
                        Debug.LogError("Empty result");
                        callback(false);
                    } else {
                        Debug.Log("Result: " + result.RawResult); // TODO: can we extract useful info from this?
                        callback(true);
                    }
                });
            }
}

public static void PostGIF(byte[] gif) {
            if (!FB.IsInitialized) {
                Init(success => {
                    if (success) PostGIF(gif);
                });
            } else if (!FB.IsLoggedIn) {
                Login(success => {
                    if (success) PostGIF(gif);
                });
            } else {
                // start upload
                WWWForm form = new WWWForm();
                form.AddField("upload_phase", "start");
                form.AddField("file_size", gif.Length.ToString());
                FB.API("me/videos", FacebookSDK.HttpMethod.POST, result => {
                    Debug.Log(result.RawResult);
                }, form);
            }
}
adiwithadidas commented 4 years ago

Same issue with me. Did you find any solutions ?

a-lotysh commented 2 years ago

I have same issue...