We recently updated our API, and I wanted to share a couple of things in case you want to build a public API too.
A few years ago we decided Bugfender users could use an API to access the logs they capturing with our tool. We thought some people would build utilities to support their daily work, like integrations with other tools, data mining, or analytics. Some people could even make those tools public, as add-ons to Bugfender.
Building the API was fairly straightforward because we had made the decision to build Bugfender with the Single Page Application architecture early on, which meant there was already a working API, only it was being used exclusively by our frontend. We could reuse that.
However, when you make an API public there are some additional things to take into account:
When we launched the API, we were expecting people would build their own tools on top of Bugfender for data mining, integrations with 3rd party platforms, and whatnot.
Therefore, we built an API access model based on "apps" that connect to Bugfender. Some apps would be for personal use, some for use within a specific organization or team, and some would be public for use by any Bugfender user.
This is also why we chose OAuth 2.0, because it's specifically built for this use case.
When we launched API access, we purposefully didn't build a UI for it. We asked people to contact us if they wanted to use it.
In hindsight, that was a great decision because we can learn how people want to use the API and we can provide them with pointers on how to get started. We also can find opportunities for improvement both in the API and the documentation.
So, the most common OAuth 2.0 use cases work like this, and this is what we built:
However, most of the users requesting API access were not interested in building an "app". They just wanted to access their own logs and make queries or export them to another service. So they were expecting a flow like this:
After a bit of investigation, personal access tokens were not what they were looking for, either, because they might not want the application to have unlimited access to their account.
The piece in the puzzle we were missing were "service accounts". Service accounts represent an application in Bugfender, have their own credentials to access it, and can be given permissions like any other user.
Luckily, OAuth 2.0 client credentials grant is exactly for this use case! So we could easily adapt to this use case. Happy ending.