Class: GoogleOAuthCli::Server
- Inherits:
-
Object
- Object
- GoogleOAuthCli::Server
- Defined in:
- lib/google-oauth-cli/server.rb
Instance Method Summary collapse
-
#initialize(port:, state:) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(port:, state:) ⇒ Server
Returns a new instance of Server.
5 6 7 8 |
# File 'lib/google-oauth-cli/server.rb', line 5 def initialize(port:, state:) @server = TCPServer.new port @state = state end |
Instance Method Details
#start ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/google-oauth-cli/server.rb', line 10 def start loop do connection = server.accept request = connection.gets data = handle_request(request) connection.write " HTTP/1.1 200 OK\n Content-Type: text/plain; charset=UTF-8\n\n OAuth request received. You can close this window now.\n DOC\n connection.close\n if data\n server.close\n return data\n end\n end\nend\n" |