1

I am new to Aqueduct and I am facing a invalid client error whenever I try to make a request to the /auth/token or /auth/code route. I have already added the OAuth2.0 client and verified the secret is correct. My request to /auth/token looks like this:

Future main() async {
  var http2 = new http.Client();
  var clientID = "com.wildfire.mobile";
  var clientSecret = "myspecialsecret ";
  var body = "username=usr&password=pwd&grant_type=password";
  var clientCredentials = new Base64Encoder().convert(
      "$clientID:$clientSecret".codeUnits);
  var response = await
  http.post(
      "http://localhost:8081/auth/token",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Basic $clientCredentials"
      },
      body: body);

And when I try logging in in /auth/code with a username in the _user database the server throws a 400:invalid_client

  • 1
    A couple of things to check: is your configuration file pointing at the right database? Did you add the client ID and secret via the aqueduct auth CLI? Also, there's a Slack channel for Aqueduct here: http://aqueductsignup.herokuapp.com – Joe Conway Aug 23 '17 at 23:32

1 Answers1

0

It was indeed a misconfiguration issue. After deleting all my databases, I added a database.yaml file, which I thought was the same as the config.yaml but apparently is not. The database.yaml looks like this:

 username: adan
 password: pass
 host: localhost
 port: 5432
 databaseName: wildfire_db

while the config.yaml looks like this:

database:
 username: adan
 password: pass
 host: localhost
 port: 5432
 databaseName: wildfire_db

I also ran the aqueduct auth and aqueduct db commands without the --connect flag, i.e. using the config files.

  • Glad to hear it worked. For clarification, config.yaml is the default name of the config file for your application. It might contain a zero, one or more database credentials, and they might be top-level, nested, etc. CLI commands that connect to a database use the --connect option to provide database credentials. As a convenience, those credentials can be placed in a database.yaml file to avoid having to type them at the CLI. The CLI won't understand the specifics of your application's configuration file, though. – Joe Conway Aug 24 '17 at 15:09