无法在渡槽的 db_and_auth/wildfire 示例中创建帐户
Can't create account in aqueduct's db_and_auth/wildfire example
我一直在努力学习如何使用 Aqueduct 的授权,但遇到了一些错误。
我发现了这个问题(),它解决了第一个错误,即在传递 _ImmutableList 时它期待一个字符串。尽管如此,每当我提出以下 POST 请求时:
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/register",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
},
body: body);
我收到 500 错误响应和以下异常:
NoSuchMethodError: The getter 'credentials' was called on null.
在
request.authorization.credentials.username
然而,在 _user table 中,我看到了我注册的用户的条目。我应该忽略这个错误还是有办法解决这个问题?
编辑:
这确实是一个配置错误的问题。删除所有数据库后,我添加了一个 database.yaml 文件,我认为它与 config.yaml 相同,但显然不是。
如果请求未通过 Authorizer,则凭据将为空。在这种情况下,您需要一个基本授权方:
router
.route("/register")
.pipe(new Authorizer.basic(authServer))
.generate(() => new RegisterController());
我一直在努力学习如何使用 Aqueduct 的授权,但遇到了一些错误。
我发现了这个问题(
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/register",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
},
body: body);
我收到 500 错误响应和以下异常:
NoSuchMethodError: The getter 'credentials' was called on null.
在
request.authorization.credentials.username
然而,在 _user table 中,我看到了我注册的用户的条目。我应该忽略这个错误还是有办法解决这个问题?
编辑: 这确实是一个配置错误的问题。删除所有数据库后,我添加了一个 database.yaml 文件,我认为它与 config.yaml 相同,但显然不是。
如果请求未通过 Authorizer,则凭据将为空。在这种情况下,您需要一个基本授权方:
router
.route("/register")
.pipe(new Authorizer.basic(authServer))
.generate(() => new RegisterController());