I was looking to make a extention to create a flarum bot. To for example filter inappropriate content etc.

But when i make an api request it sends me the following:

You have been inactive for too long.

Json POST request:

{
    "identification": "username/email",
    "password": "pass",
    "remember": false
}

Route called: /login

I'd greatly appriciate any help i can get!

    BAANAN all frontend routes are protected by CSRF tokens. That's what causes the error you see.

    If your bot needs admin access, the recommended solution is to create an API Key. API keys are created manually in the database in the api_keys table. You can then use that token using the Bearer header on all REST routes. Our documentation is still incomplete in this regard, but there are some explanations on the community-run Flarum API client https://docs.maicol07.it/en/flarum-api-client

    If your bot needs to login using user-provided credentials, there's the /api/token endpoint that can be used similarly to the login route. However I'd advise not relying that endpoint if you can avoid it because the way it works is changing in the upcoming release.

      clarkwinkelmann I have an update on this, as a developer you can already do the following in javascript:

      const flarum = require('package');
      const Flarum = new flarum('https://https://discuss.flarum.org/', true); // Flarum site link || Debug mode
      
      (async ()=>{
          const FlarumLogin = await Flarum.login('username/email', 'password');
          console.log(FlarumLogin); // This will throw the token + id
      })()

      The two objects get stored for the session, but is there also a documentation of all api routes existing? For example getting user data?

        BAANAN but is there also a documentation of all api routes existing? For example getting user data?

        Unfortunately there isn't, but the API routes all (almost-completely) follow the JSON:API schema, so format and naming should be consistent.

        The most "complete" list of API routes is in the code at https://github.com/flarum/core/blob/master/src/Api/routes.php (all routes should be prefixed with /api/). This doesn't included any routes added by bundled extensions though.

          askvortsov Thank you so much for your quick reply!

          Is it fine if i publish this package so that other people can make bots for their Flarum instances though?

            BAANAN Sure! All Flarum code is under the MIT license, we couldn't stop you if we wanted to 🤣. (although we definitely don't want to, it's always great to see more tools like this out there!)

            The one thing I have to mention is avoiding use of the trademarked Flarum name in a way that would make it seem like an official project.

              askvortsov Got it thanks! I will also add a disclaimer:

              We are **not** affiliated to Flarum.org at all, all copyright belongs to the rightfull owner!

              Would i be allowed to use the following name?: flarumbots

              Also thanks for making this amazing platform, i love it!

                BAANAN Would i be allowed to use the following name?: flarumbots

                That's a question for @luceos. 🏓

                BAANAN Also thanks for making this amazing platform, i love it!

                I'm glad to hear! We do our best 😄. And there's a lot of new cool stuff coming (relatively) soon!

                  askvortsov I'm glad to hear! We do our best 😄. And there's a lot of new cool stuff coming (relatively) soon!

                  I am interested in seeing what it has to offer, sad that it does not have support to be hosted on Pterodactyl (Webhosting panel), otherwise i would've put more time into Flarum based code.

                    BAANAN not have support to be hosted on Pterodactyl

                    Is there something in particular necessary for compatibility with Pterodactyl that Flarum is lacking? I'm not familiar with that platform.

                      BAANAN pterodactyl opens ports for different servers.

                      Hmm... I don't know of any major sites that use ports other than 443 for their websites. Users generally are not familiar with what port even means. That being said, if you serve Flarum from an alternative port and include that port in your config.php url key, that should work.

                      BAANAN And it uses a reverse proxy.

                      I don't believe Flarum has any issues with being served over reverse proxy either

                        askvortsov That is very interesting! The only thing that needs to made is a Flarum Egg then. (Egg = Software for Pterodactyl to run)
                        And then it should work fine.

                        Oh also askvortsov something that does bother me about Flarum is the fact that you cannot set a group higherarchie, this should be added with a Num calc aka: 999 = Site Creator 0 = member etc.
                        Which can be set per role.

                        That would be nice to see, oh! And role re-ordering!

                          BAANAN Flarum is the fact that you cannot set a group higherarchie, this should be added with a Num calc aka: 999 = Site Creator 0 = member etc.
                          Which can be set per role.

                          We're aware of this, it's complicated though because arbitrary numbers are arbitrary. There's a bit that can be improved with the current permissions system (especially if you have very many groups and very many tags, it's an absolute pain to configure permissions). It needs a revamp, but that'll be coming after the stable release, hopefully for v2

                            askvortsov i hope so aswell, since this is my only downside on Flarum, the rest is more then perfect!

                              BAANAN I'll also note that we have an issue for this at flarum/core1753. It's not something in scope for the next few releases, but if you have ideas on what could be a good implementation, input would be appreciated!

                                askvortsov not really, it is just something that needed to be pointed out, flarum itself is amazing, it is like discourse, but free, and open source. 🤍🤍🤍

                                Also, if you'd like to try out the package then please inform me!