lyrebot icon indicating copy to clipboard operation
lyrebot copied to clipboard

Avoid copy-pasting URL by hosting local server

Open MysteryPancake opened this issue 5 years ago • 4 comments

I noticed this bot relies on the user copy-pasting the authentication URL to Discord.

This is a great method to avoid the agony of hosting a server, so ignore this issue if you are happy with the current implementation.

I am working on a bot inspired by this one, written in JavaScript. I was initially using the same method. However, it felt quite hacky and prone to errors.

I wanted to recommend the option of hosting a local server, then reading the parameters req.query.code and req.query.state. This allows the user to immediately authenticate without copy-pasting.

Sorry if I'm being a nuisance. I've just been playing around with the API and I feel this is quite a clean and secure method.

(Note that this method requires OAuth 2.0 Authorization code Flow, so it does not work with #1)

MysteryPancake avatar Jun 08 '19 15:06 MysteryPancake

Firstly, you're definitely not being a nuisance - it's great to have other people interested in collaborating on projects :)

I did consider adding a local web server because, as you say, it's cleaner, more secure and less prone to errors. However, I decided that the barrier of getting a static IP or buying a hostname (which would be required to configure the redirect on the lyrebird API) would make it a bit too difficult for others to get started with this bot.

Maybe I could add local web server as an optional thing? Then users can choose to switch over to web based authentication when they want to tackle the associated problems.

Maybe a heroku-hosted version that I make trivial to clone would work well (as you'd get a hostname for free).

What do you think?

MartinHowarth avatar Jun 10 '19 12:06 MartinHowarth

It may be a good idea to have an option for server hosting, but it becomes complicated on Heroku. My cheap knockoff bot can currently be hosted locally or on Heroku, but I came across a number of difficulties in the process:

I first tried hosting the bot and the website through a single web dyno, which makes it easy to communicate between them. I soon discovered Heroku disables web dynos after 30 minutes of inactivity, meaning the bot will be offline unless the authorization website is constantly active.

For the bot to be online for more than 30 minutes, the website must be hosted through a web dyno, and the bot through a worker dyno. The main difficulty is communicating between them. I am trying to get around this by using a MongoDB database, but it quickly becomes complicated.

At the moment this bot would work fine using a single worker dyno, so it may not be worth going through this hassle.

MysteryPancake avatar Jun 10 '19 13:06 MysteryPancake

Yep, I host mine locally (raspberry pi). There are options out there to keep your free heroku dyno alive (e.g. https://www.veerayaaa.com/posts/free-and-easy-ways-to-prevent-heroku-free-dyno-from-sleeping/). But then you only get 20 days a month free, so the free tier doesn't work out anyway.

I think I'll add the web server option for those who do want to do the extra setup though.

MartinHowarth avatar Jun 10 '19 17:06 MartinHowarth

hi how to test this application. where i should send text and get the output.

HussainMasthan avatar Aug 06 '19 08:08 HussainMasthan