{"id":2907,"date":"2014-03-10T12:28:18","date_gmt":"2014-03-10T12:28:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/dailymotion-api-invalid-authorization-code-collection-of-common-programming-errors\/"},"modified":"2014-03-10T12:28:18","modified_gmt":"2014-03-10T12:28:18","slug":"dailymotion-api-invalid-authorization-code-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/dailymotion-api-invalid-authorization-code-collection-of-common-programming-errors\/","title":{"rendered":"Dailymotion API : &ldquo;Invalid authorization code&rdquo;-Collection of common programming errors"},"content":{"rendered":"<p>The question is obviously referring to the reference code provided by Dailymotion at https:\/\/github.com\/dailymotion\/dailymotion-sdk-php , which gives the exact error described by Hammou Moncef if you try using it to upload a video.<\/p>\n<p>Dailymotion doesn&#8217;t provide a test script that you can use with OAuth, just a unit-testing thing that uses the username\/password authentification. I used the following code and the OP must have used something similar.<\/p>\n<pre><code>require_once dirname(__FILE__) . '\/Dailymotion.php';\n\n$testVideoFile = '\/path\/to\/file';\n\n$apiKey = 'MY_API_KEY';\n$apiSecret = 'MY_API_SECRET';\n\n$api = new Dailymotion();\n\n$api-&gt;setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, $apiKey, $apiSecret, array('manage_videos'));\n$url = $api-&gt;uploadFile($testVideoFile);\n$result = $api-&gt;call('video.create', array('url' =&gt; $url));\n<\/code><\/pre>\n<p>This is after authorizing my app to upload videos to the user account, with a standard OAuth 2 flow that appears to return a valid code parameter. Except when you try to redeem it for an access token, Dailymotion gives you the previously mentioned error message.<\/p>\n<p>I applied JLepage&#8217;s fix, it changes nothing.<\/p>\n<p>There&#8217;s even a 2-year-old open issue on their Github about this, wow: https:\/\/github.com\/dailymotion\/dailymotion-sdk-php\/issues\/2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The question is obviously referring to the reference code provided by Dailymotion at https:\/\/github.com\/dailymotion\/dailymotion-sdk-php , which gives the exact error described by Hammou Moncef if you try using it to upload a video. Dailymotion doesn&#8217;t provide a test script that you can use with OAuth, just a unit-testing thing that uses the username\/password authentification. I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2907","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2907"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2907\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}