{"id":1556,"date":"2016-05-29T22:56:14","date_gmt":"2016-05-29T20:56:14","guid":{"rendered":"http:\/\/ale3andro.gr\/blog\/?p=1556"},"modified":"2016-05-29T22:56:14","modified_gmt":"2016-05-29T20:56:14","slug":"curling-from-bash-to-yandex-disk-api","status":"publish","type":"post","link":"https:\/\/ale3andro.gr\/blog\/2016\/05\/29\/curling-from-bash-to-yandex-disk-api\/","title":{"rendered":"Curling from bash to Yandex Disk API"},"content":{"rendered":"<p style=\"text-align: justify;\"><a href=\"https:\/\/ale3andro.gr\/blog\/wp-content\/uploads\/2016\/05\/5556772-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1557\" src=\"https:\/\/ale3andro.gr\/blog\/wp-content\/uploads\/2016\/05\/5556772-1.png\" alt=\"5556772\" width=\"400\" height=\"400\" srcset=\"https:\/\/ale3andro.gr\/blog\/wp-content\/uploads\/2016\/05\/5556772-1.png 400w, https:\/\/ale3andro.gr\/blog\/wp-content\/uploads\/2016\/05\/5556772-1-150x150.png 150w, https:\/\/ale3andro.gr\/blog\/wp-content\/uploads\/2016\/05\/5556772-1-300x300.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a>My\u00a0incentive was\u00a0to create an app that reads files from my <a href=\"https:\/\/disk.yandex.com\" target=\"_blank\">Yandex Disk<\/a> (using the <a href=\"https:\/\/tech.yandex.com\/disk\/api\/concepts\/about-docpage\/\" target=\"_blank\">Yandex Disk API<\/a>) using the bash from a Linux box. Unfortunately there is no much documentation in the Web (namely Google)\u00a0about using the Disk API from the Web\u00a0so I decided to write this short guide.<\/p>\n<p style=\"text-align: justify;\">(1) Login with your Yandex credentials to\u00a0<a href=\"https:\/\/oauth.yandex.com\/\" target=\"_blank\">https:\/\/oauth.yandex.com\/<\/a> and create a new app. Give title, description and at the Scope section select the subscopes that you really need (or all of them) form Yandex Disk REST API.<\/p>\n<p style=\"text-align: justify;\"><!--more--><\/p>\n<p style=\"text-align: justify;\">(2) Press the Submit button and at the next screen you will be presented with the ID, Password and Callback URL of your new app. Keep those in an open tab.<\/p>\n<p style=\"text-align: justify;\">(3) Fire up your favorite browser\u00a0and authorize the app to access your Yandex Disk files using the following URL:<\/p>\n<blockquote>\n<p style=\"text-align: justify;\">https:\/\/oauth.yandex.com\/authorize?response_type=token&#038;client_id=&lt;ID&gt;&#038;devide_id=&lt;PICK_A_DEVICE_ID&gt;&#038;device_name=&lt;PICK_A_DEVICE_NAME&gt;&#038;display=popoup&#038;force_confirm=yes&#038;state=stateString<\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">&lt;ID&gt; is your app ID you kept open in a browser tab earlier. In &lt;PICK_A_DEVICE_ID&gt; and &lt;PICK_A_DEVICE_NAME&gt; you can put whatever makes sense for your app.<\/p>\n<p style=\"text-align: justify;\">Press Allow and you will be presented with the OAuth Token. Copy it to the clipboard.<\/p>\n<p style=\"text-align: justify;\">(4) Open your favorite terminal and get some info about your Yandex Disk using the following curl command:<\/p>\n<blockquote>\n<p style=\"text-align: justify;\">curl -X GET -H &#8216;Accept: application\/json&#8217; -H &#8216;Content-Type: application\/json&#8217; -H &#8216;Authorization: OAuth &lt;OAuth token&gt;&#8217; https:\/\/cloud-api.yandex.net\/v1\/disk\/<\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">where &lt;OAuth token&gt; is exactly what the name says.<\/p>\n<p style=\"text-align: justify;\">(5) To download a file from your Disk use the following curl command:<\/p>\n<blockquote>\n<p style=\"text-align: justify;\">curl -X GET -H &#8216;Accept: application\/json&#8217; -H &#8216;Content-Type: application\/json&#8217; -H &#8216;Authorization: OAuth &lt;OAuth token&gt;&#8217; https:\/\/cloud-api.yandex.net\/v1\/disk\/resources\/download?path=%2F&lt;filename&gt;<\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">where &lt;filename&gt; is the name of the file or the path of the file that you want to download. The responce is a json stucture that contains the URL needed to download the file (href key).<\/p>\n<p style=\"text-align: justify;\">Hope it helps someone!<\/p>\n<p style=\"text-align: justify;\">Happy curling<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My\u00a0incentive was\u00a0to create an app that reads files from my Yandex Disk (using the Yandex Disk API) using the bash from a Linux box. Unfortunately there is no much documentation in the Web (namely Google)\u00a0about using the Disk API from the Web\u00a0so I decided to write this short guide. (1) Login with your Yandex credentials [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[233,274,610,611],"class_list":["post-1556","post","type-post","status-publish","format-standard","hentry","category-20","tag-bash","tag-curl","tag-yandex","tag-yandex-disk"],"_links":{"self":[{"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/posts\/1556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/comments?post=1556"}],"version-history":[{"count":0,"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/posts\/1556\/revisions"}],"wp:attachment":[{"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/media?parent=1556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/categories?post=1556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ale3andro.gr\/blog\/wp-json\/wp\/v2\/tags?post=1556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}