getauthtoken 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +24 -13
- data/lib/getauthtoken.rb +3 -4
- data/lib/getauthtoken/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36470fd7a5da225e693d83ccd434a83fe5a8a0331633fb7f070b8129bbd95a55
|
4
|
+
data.tar.gz: 88a34fe8d9e19ff26cac441a5055c3996228bc1d2e5cdfef91634eed37b6e12f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776884e842291b27555eef4268a7f15f6a55a29836f10cca04238937c168d56249d83f496ac0931d70bfbee1c2ce6048e3be39b72f10066fd045733c2181f5aa
|
7
|
+
data.tar.gz: 3c36a887c504cecd9d7085bcde5f6afff0712f5025427352275997222d006b06b14915365aa98df08570be139ee997ada4aea4dded2dee2396715735ff103488
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# getauthtoken
|
2
2
|
|
3
|
-
`getauthtoken` is a small command line utility to acquire an authorization token from [Xaptum](https://dev.xaptum.io). It's intended to speed up the process of testing API's, since an authorization token is required as a header in every request and new tokens are generated every four hours.
|
3
|
+
`getauthtoken` is a small command line utility to acquire an authorization token from [Xaptum](https://dev.xaptum.io). It's intended to speed up the process of testing API's, since an authorization token is required as a header in every request and new tokens are generated every four hours.
|
4
4
|
|
5
5
|
Running `getauthtoken` from your command line after installation (see below) will always give the current token.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
First,
|
9
|
+
First, install the gem from [Ruby Gems](https://rubygems.org). You may need to `sudo gem install` here.
|
10
10
|
|
11
11
|
```shell
|
12
|
-
$
|
13
|
-
$ cd getauthtoken
|
14
|
-
$ gem install getauthtoken-0.3.0.gem
|
12
|
+
$ gem install getauthtoken
|
15
13
|
```
|
16
14
|
|
17
|
-
Second, we'll need to create JSON file that stores your Xaptum credentials. `getauthtoken` will always use the credentials in this file to acquire your auth token.
|
15
|
+
Second, we'll need to create a JSON file `.xaptum_credentials.json` that stores your Xaptum credentials. `getauthtoken` will always use the credentials in this file to acquire your auth token.
|
16
|
+
|
17
|
+
In your `$HOME` directory, create the file `.xaptum_credentials.json` with the following structure:
|
18
18
|
|
19
19
|
```json
|
20
20
|
{
|
21
|
-
|
22
|
-
|
21
|
+
"username": "<YOUR_USERNAME>",
|
22
|
+
"password": "<YOUR_PASSWORD>"
|
23
23
|
}
|
24
24
|
```
|
25
25
|
|
@@ -27,8 +27,6 @@ Second, we'll need to create JSON file that stores your Xaptum credentials. `get
|
|
27
27
|
|
28
28
|
Simply run `getauthtoken` from the command line. The token should then appear and get copied to your clipboard.
|
29
29
|
|
30
|
-
Note that you do **not** have to be in the `getauthtoken` project directory (that you cloned earlier) to use this utility.
|
31
|
-
|
32
30
|
```shell
|
33
31
|
$ getauthtoken
|
34
32
|
Authenticating with Xaptum...
|
@@ -37,12 +35,25 @@ Your token is <TOKEN>. It has been copied to the clipboard.
|
|
37
35
|
|
38
36
|
## Development
|
39
37
|
|
38
|
+
You can clone the repository and install the dependencies with [Bundler](https://bundler.io).
|
39
|
+
|
40
|
+
```shell
|
41
|
+
$ git clone https://github.com/dylanirlbeck/getauthtoken.git
|
42
|
+
$ cd getauthtoken
|
43
|
+
$ bundle install
|
44
|
+
```
|
45
|
+
|
40
46
|
Write tests, pass tests, bump version, pull request.
|
41
47
|
|
42
|
-
|
48
|
+
- **Write tests:** Write all tests in `test/getauthtoken_test.rb`.
|
49
|
+
- **Pass tests:** Write code in `lib/getauthtoken.rb` to pass the tests. You can run tests with `$ rake test`.
|
50
|
+
- **Bump version:** The current version of the gem is in `lib/getauthtoken/version.rb`. After you've made your changes, update this version by following the format `MAJOR.MINOR.PATCH`.
|
51
|
+
- **Pull request:** Open a PR! One of the maintainers will review your changes and work with you to get them merged.
|
52
|
+
|
53
|
+
For maintainers: building new gem version and pushing to Github and Ruby Gems
|
43
54
|
|
44
55
|
```shell
|
45
|
-
$ rake
|
56
|
+
$ bundle exec rake release
|
46
57
|
```
|
47
58
|
|
48
59
|
## Contributing
|
data/lib/getauthtoken.rb
CHANGED
@@ -7,14 +7,14 @@ module Getauthtoken
|
|
7
7
|
|
8
8
|
def self.authenticate()
|
9
9
|
credentials = get_credentials()
|
10
|
-
|
10
|
+
post_credentials(credentials)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.get_credentials()
|
14
14
|
file = File.open(File.expand_path("~/.xaptum_credentials.json"))
|
15
15
|
data = JSON.load file
|
16
16
|
file.close
|
17
|
-
|
17
|
+
data
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.post_credentials(credentials)
|
@@ -23,12 +23,11 @@ module Getauthtoken
|
|
23
23
|
response = HTTP.headers("Content-Type": "application/json", "Accept": "application/json")
|
24
24
|
.post(BASE_URL, body: json)
|
25
25
|
|
26
|
-
|
26
|
+
response.code == 200 ? JSON.parse(response)["data"][0]["token"] : nil
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.pbcopy(token)
|
30
30
|
IO.popen('pbcopy', 'w') { |f| f << token }
|
31
|
-
token
|
32
31
|
end
|
33
32
|
|
34
33
|
end
|
data/lib/getauthtoken/version.rb
CHANGED