glitch_auth 0.0.1
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.
- data/lib/glitch_auth.rb +52 -0
- metadata +65 -0
data/lib/glitch_auth.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
class Glitch_Auth
|
2
|
+
|
3
|
+
# Default constructor
|
4
|
+
def initialize(token, redirect_uri)
|
5
|
+
|
6
|
+
# unique to glitch
|
7
|
+
@path = 'https://api.glitch.com/oauth2/authorize'
|
8
|
+
|
9
|
+
# unique to client
|
10
|
+
@token = token
|
11
|
+
@redirect_uri = redirect_uri
|
12
|
+
|
13
|
+
# default option values
|
14
|
+
response_type('code')
|
15
|
+
scope('identity')
|
16
|
+
state('hello-world')
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def token(value)
|
21
|
+
@token = value
|
22
|
+
end
|
23
|
+
|
24
|
+
def redirect_uri(value)
|
25
|
+
@redirect_uri = value
|
26
|
+
end
|
27
|
+
|
28
|
+
def response_type(value)
|
29
|
+
if (value == 'code' || value == 'token')
|
30
|
+
@response_type = value
|
31
|
+
else
|
32
|
+
raise ArgumentError, 'Invalid response type.'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def scope(value)
|
37
|
+
if (value == 'identity' || value == 'read' || value == 'write')
|
38
|
+
@scope = value
|
39
|
+
else
|
40
|
+
raise ArgumentError, 'Invalid scope.'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def state(value)
|
45
|
+
@state = value
|
46
|
+
end
|
47
|
+
|
48
|
+
def uri
|
49
|
+
puts "#{@path}?response_type=#{@response_type}&client_id=#{@token}&redirect_uri=#{@redirect_uri}&scope=#{@scope}&state=#{@state}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glitch_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- martian-a
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-09-25 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Currently only builds and returns the URI.
|
22
|
+
email: coder@bluegumtree.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/glitch_auth.rb
|
31
|
+
homepage: https://github.com/martian-a/glitch_auth_rubygem/
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: A simple gem for authenticating with the Glitch API.
|
64
|
+
test_files: []
|
65
|
+
|