-
-
Save rgarner/edbf98a3cc84ea85ddd31b2f3b977fe8 to your computer and use it in GitHub Desktop.
Uploadcare 401 cURL repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:15 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:64cf3b40abc4c9d9f8f6f18b627d3d37a0d4b2f2' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
# => 200 | |
curl -v -X DELETE -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/storage/" | |
# => 302 | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
# => 401 with body {"detail":"Invalid signature. Please check your secret key."} | |
# GET from `rescue` block | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:19038d45f7f5b8bade4f0fef48c3265a4f3aef70' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
# => 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:15 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:64cf3b40abc4c9d9f8f6f18b627d3d37a0d4b2f2' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
#Note: Unnecessary use of -X or --request, GET is already inferred. | |
#* Trying 54.86.87.165... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (54.86.87.165) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> GET /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:15 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:64cf3b40abc4c9d9f8f6f18b627d3d37a0d4b2f2 | |
#> | |
#< HTTP/1.1 200 OK | |
#< Date: Tue, 17 Apr 2018 10:02:53 GMT | |
#< Content-Type: application/vnd.uploadcare-v0.3+json | |
#< Content-Length: 546 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Warning: 199 Miscellaneous warning: Please use API version 0.5, not 0.3 | |
#< Allow: GET, DELETE, HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
# | |
#{ | |
# "datetime_removed": "2018-04-17T09:59:37.345016Z", | |
# "datetime_stored": null, | |
# "datetime_uploaded": "2018-04-13T15:29:32.278712Z", | |
# "image_info": { | |
# "orientation": null, | |
# "sequence": false, | |
# "format": "JPEG", | |
# "height": 1536, | |
# "width": 2048, | |
# "geo_location": null, | |
# "datetime_original": null, | |
# "dpi": null | |
# }, | |
# "is_image": true, | |
# "is_ready": true, | |
# "mime_type": "image/jpeg", | |
# "original_file_url": null, | |
# "original_filename": "broken-door.jpg", | |
# "size": 293898, | |
# "url": "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/", | |
# "uuid": "808ee843-2f45-4ed3-8e3f-c34822a453e4", | |
# "source": null | |
#} | |
curl -v -X DELETE -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/storage/" | |
#* Trying 34.205.0.129... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (34.205.0.129) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> DELETE /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/storage/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:16 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d | |
#> | |
#< HTTP/1.1 302 Found | |
#< Date: Tue, 17 Apr 2018 10:04:45 GMT | |
#< Content-Type: text/html; charset=utf-8 | |
#< Content-Length: 0 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Warning: 199 Miscellaneous warning: Please use API version 0.5, not 0.3 | |
#< Location: /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ | |
#< Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
#* Trying 34.205.0.129... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (34.205.0.129) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> DELETE /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/storage/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:16 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d | |
#> | |
#< HTTP/1.1 302 Found | |
#< Date: Tue, 17 Apr 2018 10:04:45 GMT | |
#< Content-Type: text/html; charset=utf-8 | |
#< Content-Length: 0 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Warning: 199 Miscellaneous warning: Please use API version 0.5, not 0.3 | |
#< Location: /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ | |
#< Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
#➜ mytvh-web git:(uploadcare-deleting-experiments) ✗ curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 100:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
#Note: Unnecessary use of -X or --request, GET is already inferred. | |
#* Trying 34.205.0.129... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (34.205.0.129) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> GET /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:16 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d | |
#> | |
#< HTTP/1.1 401 Unauthorized | |
#< Date: Tue, 17 Apr 2018 10:05:19 GMT | |
#< Content-Type: application/vnd.uploadcare-v0.3+json | |
#< Content-Length: 61 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Allow: HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< WWW-Authenticate: Uploadcare | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
#{"detail":"Invalid signature. Please check your secret key."}% | |
#### | |
### GET issued from rescue block | |
### | |
curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 10:00:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:19038d45f7f5b8bade4f0fef48c3265a4f3aef70' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
#Note: Unnecessary use of -X or --request, GET is already inferred. | |
#* Trying 34.205.0.129... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (34.205.0.129) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> GET /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:16 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:45ee8d920916157a43f110d492f0f9e8d11f9e9d | |
#> | |
#< HTTP/1.1 401 Unauthorized | |
#< Date: Tue, 17 Apr 2018 10:05:19 GMT | |
#< Content-Type: application/vnd.uploadcare-v0.3+json | |
#< Content-Length: 61 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Allow: HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< WWW-Authenticate: Uploadcare | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
#{"detail":"Invalid signature. Please check your secret key."}% ➜ mytvh-web git:(uploadcare-deleting-experiments) ✗ curl -v -X GET -H 'Accept: application/vnd.uploadcare-v0.3+json' -H 'User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698' -H 'Date: Tue, 17 Apr 2018 100:16 -0000' -H 'Authorization: Uploadcare 7be49678a22235155698:19038d45f7f5b8bade4f0fef48c3265a4f3aef70' "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/" | |
#Note: Unnecessary use of -X or --request, GET is already inferred. | |
#* Trying 54.86.87.165... | |
#* TCP_NODELAY set | |
#* Connected to api.uploadcare.com (54.86.87.165) port 443 (#0) | |
#* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | |
#* Server certificate: *.uploadcare.com | |
#* Server certificate: Amazon | |
#* Server certificate: Amazon Root CA 1 | |
#* Server certificate: Starfield Services Root Certificate Authority - G2 | |
#> GET /files/808ee843-2f45-4ed3-8e3f-c34822a453e4/ HTTP/1.1 | |
#> Host: api.uploadcare.com | |
#> Accept: application/vnd.uploadcare-v0.3+json | |
#> User-Agent: uploadcare-ruby/2.5.0.0/1.1.0/7be49678a22235155698 | |
#> Date: Tue, 17 Apr 2018 10:00:16 -0000 | |
#> Authorization: Uploadcare 7be49678a22235155698:19038d45f7f5b8bade4f0fef48c3265a4f3aef70 | |
#> | |
#< HTTP/1.1 200 OK | |
#< Date: Tue, 17 Apr 2018 10:06:25 GMT | |
#< Content-Type: application/vnd.uploadcare-v0.3+json | |
#< Content-Length: 546 | |
#< Connection: keep-alive | |
#< Server: nginx | |
#< X-XSS-Protection: 1; mode=block | |
#< X-Content-Type-Options: nosniff | |
#< Vary: Accept | |
#< Warning: 199 Miscellaneous warning: Please use API version 0.5, not 0.3 | |
#< Allow: GET, DELETE, HEAD, OPTIONS | |
#< Access-Control-Allow-Origin: https://uploadcare.com | |
#< X-Frame-Options: SAMEORIGIN | |
#< | |
#* Connection #0 to host api.uploadcare.com left intact | |
#{ | |
# "datetime_removed": "2018-04-17T09:59:37.345016Z", | |
# "datetime_stored": null, | |
# "datetime_uploaded": "2018-04-13T15:29:32.278712Z", | |
# "image_info": { | |
# "orientation": null, | |
# "sequence": false, | |
# "format": "JPEG", | |
# "height": 1536, | |
# "width": 2048, | |
# "geo_location": null, | |
# "datetime_original": null, | |
# "dpi": null | |
# }, | |
# "is_image": true, | |
# "is_ready": true, | |
# "mime_type": "image/jpeg", | |
# "original_file_url": null, | |
# "original_filename": "broken-door.jpg", | |
# "size": 293898, | |
# "url": "https://api.uploadcare.com/files/808ee843-2f45-4ed3-8e3f-c34822a453e4/", | |
# "uuid": "808ee843-2f45-4ed3-8e3f-c34822a453e4", | |
# "source": null | |
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_id = "a-valid-uuid" | |
file = api.file(file_id) | |
file.load_data! | |
begin | |
file.delete | |
rescue Uploadcare::Error::RequestError::Unauthorized => e | |
puts "Rescued a 401 on file deletion" # this always happens | |
file = api.file(file_id) | |
file.load_data! # we can still load it | |
puts file.deleted? # will return true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment