Class: Glitch_Auth
- Inherits:
-
Object
- Object
- Glitch_Auth
- Defined in:
- lib/glitch_auth.rb
Overview
This class builds a url that can be used to authenticate with the API for Glitch, the game (www.glitch.com).
Instance Method Summary (collapse)
-
- (Glitch_Auth) initialize(token, redirect_uri)
constructor
Default constructor.
- - (Object) redirect_uri(value)
- - (Object) response_type(value)
- - (Object) scope(value)
- - (Object) state(value)
- - (Object) token(value)
-
- (String) uri
A URI for authenticating with Glitch, customised as per the settings specified.
Constructor Details
- (Glitch_Auth) initialize(token, redirect_uri)
Default constructor.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/glitch_auth.rb', line 9 def initialize(token, redirect_uri) # unique to glitch @path = 'https://api.glitch.com/oauth2/authorize' # unique to client @token = token @redirect_uri = redirect_uri # default option values response_type('code') scope('identity') state('hello-world') end |
Instance Method Details
- (Object) redirect_uri(value)
32 33 34 |
# File 'lib/glitch_auth.rb', line 32 def redirect_uri(value) @redirect_uri = value end |
- (Object) response_type(value)
37 38 39 40 41 42 43 |
# File 'lib/glitch_auth.rb', line 37 def response_type(value) if (value == 'code' || value == 'token') @response_type = value else raise ArgumentError, 'Invalid response type.' end end |
- (Object) scope(value)
46 47 48 49 50 51 52 |
# File 'lib/glitch_auth.rb', line 46 def scope(value) if (value == 'identity' || value == 'read' || value == 'write') @scope = value else raise ArgumentError, 'Invalid scope.' end end |
- (Object) state(value)
55 56 57 |
# File 'lib/glitch_auth.rb', line 55 def state(value) @state = value end |
- (Object) token(value)
27 28 29 |
# File 'lib/glitch_auth.rb', line 27 def token(value) @token = value end |
- (String) uri
A URI for authenticating with Glitch, customised as per the settings specified
60 61 62 |
# File 'lib/glitch_auth.rb', line 60 def uri "#{@path}?response_type=#{@response_type}&client_id=#{@token}&redirect_uri=#{@redirect_uri}&scope=#{@scope}&state=#{@state}" end |