Gavin
Gavin

Reputation: 6394

Unsufficient scope when attempting to update video

I'm currently working on a project that allows staff to upload videos to DailyMotion via an admin interface without having to touch DailyMotion it self (the video's are embedded on our site but hosted on DM.)

Because of this, I am using /file/upload to generate a public upload URL and then using /me/videos to publish the video and set a few settings.

// Initiatlise and authenticate.
$api = new Dailymotion();
$api->setGrantType(
    Dailymotion::GRANT_TYPE_PASSWORD, 
    'api_key', 
    'api_key_secret', 
    array(
        'write', 
        'delete', 
        'manage_videos'
    ), array(
        'username' => 'username',
        'password' => 'password'
    )
);

// Get public upload/progress urls.
$urls = $api->get('/file/upload');

// Upload result with video URL.
$upload_result = {
    acodec: "AAC",
    bitrate: 1248721,
    dimension: "1280x720",
    duration: 13504,
    format: "MPEG-4",
    hash: "...",
    name: "...",
    seal: "...",
    size: 2107842,
    streamable: "No",
    url: "...",
    vcodec: "AVC"
};

// Update video to set published etc.
$result = $api->post(
    '/me/videos',
    array(
        'url' => $upload_result->url,
        'title' => 'Some title',
        'publish' => true
    )
);

From the above, I am setting the manage_videos scope and it's still reporting back that I don't have the correct scope?

Can anyone point out where I'm going wrong?

Thanks

Upvotes: 0

Views: 187

Answers (1)

dailymotion
dailymotion

Reputation: 1596

If you're passing the manage_videos scope and still get an error mentioning you don't have the correct scope, it must be due to an existing session.

One of the problems with OAuth 2.0 is that the specification doesn't offer any mechanism to upgrade the scope of an existing session. To add new scopes to an already existing session, you first need to call the Dailymotion::logout() method and start a new session with your new list of scopes (see the note mentioning this at https://developer.dailymotion.com/tools/sdks#sdk-php-authentication ).

Upvotes: 1

Related Questions