vimeo / vimeo.php

Official PHP library for the Vimeo API.
https://developer.vimeo.com
Apache License 2.0
448 stars 209 forks source link

Uploading video through SSL #51

Closed gvhuyssteen closed 9 years ago

gvhuyssteen commented 9 years ago

Trying to upload a video that sits on the web server to Vimeo and I'm getting the following error:

A valid user token must be passed. Status code: 401

I'm using Laravel 4.2 with "vinkla/vimeo": "~1.0" and Vimeo PHP Api version=3.2 (vimeo.php 1.0;)

The config file has the correct keys used to upload.

Uploading from localhost works perfectly.

The recommended fix from this website: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ have been implemented but still getting the same error.

Currently my Vimeo.php file have these fixes implemented: https://github.com/dstelljes/vimeo.php/commit/babb5da75a65e56717c55f1f287acbc2583292e0

I'm still getting the same error. "A valid user token must be passed"

Are there any other changes I need to implement to get this working?

vinkla commented 9 years ago

Is the access token in the configuration file? They had a similar problem in #50. Please also look into what @Dashron wrote in https://github.com/vimeo/vimeo.php/issues/47#issuecomment-72739413. Could you share the controller/manager class executing the error?

gvhuyssteen commented 9 years ago

Hi Vinkla,

First of all, thank you for the time to write a Laravel package for Vimeo!

I have tried leaving the access token null as well as entering the access token that I had from vimeo.

Always the same error. "A valid user token must be passed."

vinkla commented 9 years ago

Anytime! I needed it myself. Did you look through the other issues? Did they help?

gvhuyssteen commented 9 years ago

I have been looking and reading through fixes for 2 days now. Posting on Github was my last option.

vinkla commented 9 years ago

The fix you're writing about could soon get merged in #41.

Could you please post the contents of the $ticket variable from here: https://github.com/vimeo/vimeo.php/blob/master/src/Vimeo/Vimeo.php#L349

gvhuyssteen commented 9 years ago

Let me give a bit more detail.

A user uploads a video using a form to my web server. I then use Vimeo::upload to upload the file from a public directory to Vimeo.

$vimeo = Vimeo::upload($directory . '/' . $filename, false);

We are using a wildcard SSL certificate (If that matters in any way)

Here is what I get back in $ticket:

{
    "error": {
        "type": "Vimeo\\Exceptions\\VimeoUploadException",
        "message": "{\"body\":{\"error\":\"A valid user token must be passed.\"},\"status\":401,\"headers\":{\"Date\":\"Thu, 19 Mar 2015 12\",\"Server\":\"nginx\",\"Content-Type\":\"application\\\/vnd.vimeo.error+json\",\"Cache-Control\":\"no-cache, max-age=315360000\",\"WWW-Authenticate\":\"Bearer error=\\\"invalid_token\\\"\",\"Expires\":\"Sun, 16 Mar 2025 12\",\"Content-Length\":\"46\",\"Accept-Ranges\":\"bytes\",\"Via\":\"1.1 varnish\",\"X-Served-By\":\"cache-lcy1128-LCY\",\"X-Cache\":\"MISS\",\"X-Cache-Hits\":\"0\",\"X-Timer\":\"S1426767198.877492,VS0,VE87\",\"Vary\":\"Accept,Vimeo-Client-Id,Accept-Encoding\"}}",
        "file": "\/var\/www\/dev\/vendor\/vimeo\/vimeo-api\/src\/Vimeo\/Vimeo.php",
        "line": 345
    }
}
vinkla commented 9 years ago

@Dashron do you have any input on this?

Dashron commented 9 years ago

The access token you use has to be authenticated to a user, so you should be able to successfully request GET https://api.vimeo.com/me?access_token=XXXX.

If that url doesn't work, try GET https://api.vimeo.com/users/dashron?access_token=XXXX. If the first url doesn't work, but the second one does you have a client authentication token. These are not associated with users, and you can not upload a video without a user access token.

If the second url doesn't work your token is invalid and you should generate a new one.

If both urls work, and you still can not generate a token your app likely does not have upload permissions for that user. There are many different levels of permission and you might only have access to upload on behalf of the owner of the api application. To verify this you can contact vimeo through vimeo.com/help/contact

gvhuyssteen commented 9 years ago

Thank you for your response. Both urls work and I have selected the upload permission when I created the access token.

I will contact Vimeo support for further investigation.

gvhuyssteen commented 9 years ago

Vimeo support is so very slow... Been waiting 4 days for a response now.

gvhuyssteen commented 9 years ago

6 days in and no feedback from Vimeo support. Is there anyone else that can help me?

Dashron commented 9 years ago

There have been some issues with Vimeo's support service over the last couple of days. None of the support cases we have received in the last couple of days included the message you provided earlier. Can you submit a new request and ask for it to be assigned immediately to Aaron?

gvhuyssteen commented 9 years ago

Thank you for coming back to me, Dashron. I have resubmitted the query to the API support team.

gvhuyssteen commented 9 years ago

After regenerating a token and added all available scopes to the token, I'm getting a different error.

Scopes used:

public private purchased create edit delete interact upload

I changed the access key in the config file to the new one I just generated.

This is the response that I am now getting back through an SSL connection.

{
    "error": {
        "type": "Vimeo\\Exceptions\\VimeoUploadException",
        "message": "{\"body\":null,\"status\":0,\"headers\":[]}",
        "file": "/var/www/dev/vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php",
        "line": 347
    }
}

These are my curl option defaults:

$curl_opt_defaults = array(
            CURLOPT_HEADER => 1,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_CAINFO => dirname(__FILE__) . 'ca.crt'
        );

Why is this so difficult?

Even though we support Vimeo with a PRO account, Vimeo is not supporting us with sufficient support as we had not received any feedback from Vimeo.

On the verge of moving away from Vimeo to store and stream videos from.

gvhuyssteen commented 9 years ago

Moved the whole laravel based website to a brand new server with no SSL installed.

I did a clean vendor install, meaning that this Vimeo package was installed as is with no modifications.

This is the error I'm receiving now.

{
    "error": {
        "type": "Vimeo\\Exceptions\\VimeoUploadException",
        "message": "Unable to get an upload ticket.",
        "file": "/var/www/disturping.com/vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php",
        "line": 336
    }
}

I tried two different access tokens. Same errors.

Officially confused.

Dashron commented 9 years ago

{"body":null,"status":0,"headers":[]} is usually an ssl based issue (status 0 means it never left the servers)

"Unable to get an upload ticket" is a bad error message that we are going to be fixing soon. You can find it here: https://github.com/vimeo/vimeo.php/blob/master/src/Vimeo/Vimeo.php#L350. If you log out the $ticket variable from the condition on the line above you will see a much clearer failure cause.

gvhuyssteen commented 9 years ago

Hi Dashron,

When I log the $ticket, I get the same error message as before. (Post #1)

We realised that there was something wrong with our mail server and could not receive the responses from Vimeo support. I have now pushed back to support and hopefully we can sort this issue out.

Apologies for the lashing out earlier. I realise that it was completely my fault for not receiving support emails.

Dashron commented 9 years ago

No worries, we have definitely encountered that issue before, and it frustrates us as much as it must frustrate you.

I found your ticket and just replied with some more questions about your access token.

gvhuyssteen commented 9 years ago

So after spending a bit more time on the Vimeo php library, I finally solved the issue.

The client_id, client_secret and access_token was not being set once I moved it to the dev server. Using the same project on local host actually sets the credentials correctly.

Thank you all for your help.

Dashron commented 9 years ago

Glad to hear it's fixed. Let us know if you encounter any more issues!