litaio / lita

ChatOps for Ruby.
https://www.lita.io
MIT License
1.68k stars 179 forks source link

Adding HTTP URL for adapters #216

Closed grokify closed 4 years ago

grokify commented 7 years ago

Is it possible to add an HTTP URL for an adapter? I know this can be added for handlers, but when I tro to add it for an adapter, I receive the following error:

Gem Load Error is: undefined local variable or method `http' for Lita::Adapters::Glip:Class
jimmycuadra commented 7 years ago

Can you clarify what you mean by HTTP URL? Are you trying to make an outgoing HTTP request, or add a route for incoming HTTP requests?

grokify commented 7 years ago

I'm trying to have the bot handle OAuth 2.0 authorization code grant for an adapter. For OAuth, I need to have a redirect URL on the bot which returns an authorization code in the URL which I will then need to extract and exchange for an access token.

Today, in a handler, I can have a URL like the following from lita-line:

http.post "/callback", :callback

https://github.com/aar0nTw/lita-line/blob/master/lib/lita/handlers/webhook.rbhttps://github.com/aar0nTw/lita-line/blob/master/lib/lita/handlers/webhook.rb#L49

However, it seems I cannot add a callback URL to an adapter, which is what I need.

jimmycuadra commented 7 years ago

You need to use a handler for incoming HTTP requests. You can include a handler in the same gem as your adapter so users don't need to install two gems for the full functionality.