[backend/masto-client] Improve error message when requesting an oauth token with a grant_type other than authorization_code

This commit is contained in:
Laura Hausmann 2024-07-12 17:48:54 +02:00
parent 0cd754f4c2
commit 9c8debb5ed
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -89,7 +89,7 @@ public class AuthController(DatabaseContext db, MetaService meta) : ControllerBa
{
//TODO: app-level access (grant_type = "client_credentials")
if (request.GrantType != "authorization_code")
throw GracefulException.BadRequest("Invalid grant_type");
throw GracefulException.BadRequest($"Invalid grant_type, only authorization_code is supported.");
var token = await db.OauthTokens.FirstOrDefaultAsync(p => p.Code == request.Code &&
p.App.ClientId == request.ClientId &&
p.App.ClientSecret == request.ClientSecret);