pcloud_api 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +11 -1
- data/{RELEASEING.md → RELEASING.md} +4 -3
- data/lib/pcloud/client.rb +35 -0
- data/lib/pcloud/version.rb +1 -1
- data/lib/pcloud_api.rb +2 -0
- data/pcloud_api.gemspec +1 -1
- metadata +12 -11
- data/bin/generate_access_token +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd54a78436ca98f3be29ff57665673844bb2ecedbf5a31897bebc3aece48c32
|
4
|
+
data.tar.gz: bf3a50ccccbaddce4ce6cf39a009ffb105062e307619f7db3ef9c2555e5604fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86f725489551a4640a236da72e7debfcecdd41858f18980c14a7c9a8ac4f85ce4475e7def2485656c1f9372d34a9527b5ad39a4b3817e3139261f695a89ec42
|
7
|
+
data.tar.gz: 899a5a928e5e86a1390e813e2dfeb1d9967171393a5d9d186a848262e9ff2ee50b7b1643152f27a1a3289fd446efaccababa42ca5c9036fc5eef2641ca952a19
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.2.7 2025-08-01
|
2
|
+
|
3
|
+
**Changes**
|
4
|
+
1. Moved the script to generate an access token inside the gem itself so that it can now be called with `Pcloud::Client.generate_access_token`
|
5
|
+
2. Opened up the dependency requirements for HTTParty
|
6
|
+
|
1
7
|
## 0.2.6 2024-06-09
|
2
8
|
|
3
9
|
**Bugfix**
|
data/README.md
CHANGED
@@ -32,7 +32,17 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
### Generating an access token
|
34
34
|
|
35
|
-
To use the `pcloud_api` client, you will need to first generate an access token. You may do this by
|
35
|
+
To use the `pcloud_api` client, you will need to first generate an access token. You may do this by opening a Rails console or IRB session and entering the following code:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
irb(main):001:0> require "pcloud_api"
|
39
|
+
=> true
|
40
|
+
irb(main):002:0> Pcloud::Client.generate_access_token
|
41
|
+
=== Follow these steps to generate a pCloud app and access token ===
|
42
|
+
...
|
43
|
+
```
|
44
|
+
|
45
|
+
You will be presented with an interactive prompt which will take you through the process of setting up a pCloud app and completing the OAuth2 flow in the browser. At the end of the prompt, your new access token will be displayed. You should save this value in a secure location as it can be used to access your pCloud account data.
|
36
46
|
|
37
47
|
### Configuration
|
38
48
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# Cutting a new release of the pCloud API gem:
|
2
2
|
1. Update the gem version in `lib/pcloud/version.rb`.
|
3
3
|
2. Make any documentation updates.
|
4
|
-
3.
|
5
|
-
4.
|
4
|
+
3. Push and merge all changes.
|
5
|
+
4. Tag a new release in GitHub and summarize the changes since the last release.
|
6
|
+
5. Build the gem locally: `gem build pcloud_api.gemspec`.
|
6
7
|
* To test the gem in a local project, you can install it with `gem install --local pcloud_api-<VERSION>.gem`
|
7
8
|
* Make sure to update your `Gemfile` to point at the path where you built the gem, i.e. `gem "pcloud_api", path: "~/src/pcloud_api/"`
|
8
|
-
|
9
|
+
6. Publish the gem to rubygems.org: `gem push pcloud_api-<VERSION>.gem`.
|
data/lib/pcloud/client.rb
CHANGED
@@ -33,6 +33,41 @@ module Pcloud
|
|
33
33
|
json_response
|
34
34
|
end
|
35
35
|
|
36
|
+
def generate_access_token
|
37
|
+
puts "=== Follow these steps to generate a pCloud app and access token ==="
|
38
|
+
puts "1. Register an app at `https://docs.pcloud.com/my_apps/`"
|
39
|
+
|
40
|
+
puts "2. Enter the client id and secret for the app:"
|
41
|
+
print "Client ID > "
|
42
|
+
client_id = $stdin.gets.chomp
|
43
|
+
|
44
|
+
print "Client Secret > "
|
45
|
+
client_secret = $stdin.gets.chomp
|
46
|
+
|
47
|
+
puts "3. Enter the data region of your pCloud account [EU/US]:"
|
48
|
+
print "> "
|
49
|
+
region_specific_api_base = $stdin.gets.chomp == "EU" ? "eapi.pcloud.com" : "api.pcloud.com"
|
50
|
+
|
51
|
+
puts "4. Navigate to this URL to start the access code flow:"
|
52
|
+
puts "`https://my.pcloud.com/oauth2/authorize?client_id=#{client_id}&response_type=code`"
|
53
|
+
puts "5. After logging in, enter the access code provided below:"
|
54
|
+
print "> "
|
55
|
+
access_code = $stdin.gets.chomp
|
56
|
+
|
57
|
+
puts "6. Requesting access token from pCloud..."
|
58
|
+
query = { client_id: client_id, client_secret: client_secret, code: access_code }
|
59
|
+
response = HTTParty.post(
|
60
|
+
"https://#{region_specific_api_base}/oauth2_token?#{URI.encode_www_form(query)}",
|
61
|
+
headers: { "Accept" => "application/json" }
|
62
|
+
)
|
63
|
+
|
64
|
+
json_response = JSON.parse(response.body)
|
65
|
+
raise json_response["error"] if json_response["error"]
|
66
|
+
puts "Done! Your access token is: \n#{json_response["access_token"]}"
|
67
|
+
puts "\nStore this value somewhere secure as it can be used to access your"
|
68
|
+
puts "pCloud account data and it will not be shown again."
|
69
|
+
end
|
70
|
+
|
36
71
|
private
|
37
72
|
|
38
73
|
def data_region_from_config_or_env
|
data/lib/pcloud/version.rb
CHANGED
data/lib/pcloud_api.rb
CHANGED
data/pcloud_api.gemspec
CHANGED
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "pry", "~> 0.13"
|
31
31
|
|
32
|
-
spec.add_dependency "httparty", "
|
32
|
+
spec.add_dependency "httparty", ">= 0.16", "< 1.0"
|
33
33
|
spec.add_dependency "tzinfo"
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pcloud_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hunsche Jones
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-08-01 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -76,16 +75,22 @@ dependencies:
|
|
76
75
|
name: httparty
|
77
76
|
requirement: !ruby/object:Gem::Requirement
|
78
77
|
requirements:
|
79
|
-
- - "
|
78
|
+
- - ">="
|
80
79
|
- !ruby/object:Gem::Version
|
81
80
|
version: '0.16'
|
81
|
+
- - "<"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.0'
|
82
84
|
type: :runtime
|
83
85
|
prerelease: false
|
84
86
|
version_requirements: !ruby/object:Gem::Requirement
|
85
87
|
requirements:
|
86
|
-
- - "
|
88
|
+
- - ">="
|
87
89
|
- !ruby/object:Gem::Version
|
88
90
|
version: '0.16'
|
91
|
+
- - "<"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.0'
|
89
94
|
- !ruby/object:Gem::Dependency
|
90
95
|
name: tzinfo
|
91
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +105,6 @@ dependencies:
|
|
100
105
|
- - ">="
|
101
106
|
- !ruby/object:Gem::Version
|
102
107
|
version: '0'
|
103
|
-
description:
|
104
108
|
email:
|
105
109
|
- joshua@hunschejones.com
|
106
110
|
executables: []
|
@@ -113,10 +117,9 @@ files:
|
|
113
117
|
- Gemfile
|
114
118
|
- LICENSE.txt
|
115
119
|
- README.md
|
116
|
-
-
|
120
|
+
- RELEASING.md
|
117
121
|
- Rakefile
|
118
122
|
- bin/console
|
119
|
-
- bin/generate_access_token
|
120
123
|
- bin/setup
|
121
124
|
- lib/pcloud/client.rb
|
122
125
|
- lib/pcloud/file.rb
|
@@ -134,7 +137,6 @@ metadata:
|
|
134
137
|
homepage_uri: https://github.com/jhunschejones/pcloud_api
|
135
138
|
source_code_uri: https://github.com/jhunschejones/pcloud_api
|
136
139
|
changelog_uri: https://github.com/jhunschejones/pcloud_api/blob/master/CHANGELOG.md
|
137
|
-
post_install_message:
|
138
140
|
rdoc_options: []
|
139
141
|
require_paths:
|
140
142
|
- lib
|
@@ -149,8 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
- !ruby/object:Gem::Version
|
150
152
|
version: '0'
|
151
153
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
154
|
+
rubygems_version: 3.6.3
|
154
155
|
specification_version: 4
|
155
156
|
summary: A Ruby library for interacting with the pCloud API
|
156
157
|
test_files: []
|
data/bin/generate_access_token
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
require "uri"
|
5
|
-
require "net/http"
|
6
|
-
|
7
|
-
class String
|
8
|
-
def green; "\033[32m#{self}\033[0m" end
|
9
|
-
def cyan; "\033[36m#{self}\033[0m" end
|
10
|
-
end
|
11
|
-
|
12
|
-
puts "1. Register an app at `https://docs.pcloud.com/my_apps/`".cyan
|
13
|
-
|
14
|
-
|
15
|
-
puts "2. Enter the client id and secret for the app:".cyan
|
16
|
-
print "Client ID > "
|
17
|
-
client_id = $stdin.gets.chomp.freeze
|
18
|
-
print "Client Secret > "
|
19
|
-
client_secret = $stdin.gets.chomp.freeze
|
20
|
-
|
21
|
-
|
22
|
-
puts "3. Enter the data region of your pCloud account [EU/US]:".cyan
|
23
|
-
print "> "
|
24
|
-
region_specific_api_base = $stdin.gets.chomp == "EU" ? "eapi.pcloud.com" : "api.pcloud.com"
|
25
|
-
|
26
|
-
|
27
|
-
puts "4. Navigate to this URL to start the access code flow:".cyan
|
28
|
-
puts "`https://my.pcloud.com/oauth2/authorize?client_id=#{client_id}&response_type=code`"
|
29
|
-
|
30
|
-
|
31
|
-
puts "5. After logging in, enter the access code provided below:".cyan
|
32
|
-
print "> "
|
33
|
-
access_code = $stdin.gets.chomp.freeze
|
34
|
-
|
35
|
-
|
36
|
-
puts "6. Requesting access token from pCloud...".cyan
|
37
|
-
query = { client_id: client_id, client_secret: client_secret, code: access_code }
|
38
|
-
uri = URI.parse("https://#{region_specific_api_base}/oauth2_token?#{URI.encode_www_form(query)}")
|
39
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
40
|
-
http.use_ssl = true
|
41
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
42
|
-
request["Accept"] = "application/json"
|
43
|
-
response = http.request(request)
|
44
|
-
json_response = JSON.parse(response.body)
|
45
|
-
raise json_response["error"] if json_response["error"]
|
46
|
-
puts "Done! Your access token is: #{json_response["access_token"]}".green
|