Permalink
Browse files

Fix kinda broken authentication workflow

  • Loading branch information...
1 parent 02275fb commit 17118cbec87383dc79ba11482506a8e48e85aa7b @rs rs committed Oct 21, 2012
Showing with 9 additions and 7 deletions.
  1. +7 −5 Dailymotion.php
  2. +2 −2 README.md
View
12 Dailymotion.php
@@ -91,7 +91,8 @@ class Dailymotion
* or Dailymotion::GRANT_TYPE_PASSWORD.
* @param $apiKey the API key
* @param $apiSecret the API secret
- * @param $scope mixed the permission scope requested (can be none or any of 'read', 'write', 'delete').
+ * @param $scope mixed the permission scope requested (see http://www.dailymotion.com/doc/api/authentication.html#requesting-extended-permissions
+ * for a list of available permissions).
* To requested several scope keys, use an array or separate keys by whitespaces.
* @param $info Array info associated to the chosen grant type
*
@@ -155,10 +156,11 @@ public function setGrantType($type, $apiKey, $apiSecret, Array $scope = null, Ar
* Get an authorization URL for use with redirects. By default, full page redirect is assumed.
* If you are using a generated URL with a window.open() call in Javascript, you can pass in display=popup.
*
- * @param $scope Array a list of requested scope (allowed: create, read, update, delete)
+ * @param $scope Array a list of requested scope (see http://www.dailymotion.com/doc/api/authentication.html#requesting-extended-permissions
+ * for a list of available permissions)
* @param $display String can be "page" (default, full page), "popup" or "mobile"
*/
- public function getAuthorizationUrl($redirectUri = null, $scope = array(), $display = 'page')
+ public function getAuthorizationUrl($display = 'page')
{
if ($this->grantType !== self::GRANT_TYPE_AUTHORIZATION)
{
@@ -170,7 +172,7 @@ public function getAuthorizationUrl($redirectUri = null, $scope = array(), $disp
'response_type' => 'code',
'client_id' => $this->grantInfo['key'],
'redirect_uri' => $this->grantInfo['redirect_uri'],
- 'scope' => is_array($scope) ? implode(' ', $scope) : $scope,
+ 'scope' => is_array($this->grantInfo['scope']) ? implode(' ', $scope) : $scope,
'display' => $display,
), null, '&');
}
@@ -184,7 +186,7 @@ public function getAuthorizationUrl($redirectUri = null, $scope = array(), $disp
*/
public function uploadFile($filePath)
{
- $result = $this->call('file.upload');
+ $result = $this->get('/file/upload');
$timeout = $this->timeout;
$this->timeout = null;
$result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true);
View
4 README.md
@@ -53,12 +53,12 @@ responsibility to ask the user for its credentials. Make sure you API secret rem
if (isset($_POST['username']) || isset($_POST['password']))
{
- $api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, $scope = 'read write'),
+ $api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, $scope = array('manage_videos'),
array('username' => $_POST['username'], 'password' => $_POST['password']));
}
else
{
- $api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, $scope = 'read write');
+ $api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, $scope = array('manage_videos'));
}
try

0 comments on commit 17118cb

Please sign in to comment.