2017-08-22 5 views
0

Aqueductの権限の使用方法を習得しようとしていますが、いくつかのエラーで苦労しています。 この質問(OAuth Error using Aqueduct, mismatched ManagedPropertyType)は、_ImmutableListが渡されている間に文字列を期待しているという最初のエラーを解決しました。私は、次のPOSTリクエスト作る時はいつでもそれにも関わらず、:で、それにも関わらず水道局のdb_and_auth/wildfireの例でアカウントを作成できません

NoSuchMethodError: The getter 'credentials' was called on null. 

request.authorization.credentials.username 

中:

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エラーと、次の例外を取得します_userテーブル登録したユーザのエントリが表示されます。私は間違いを無視しなければならないのでしょうか、あるいはこの問題を解決するためにどこかにありますか?

編集: これは本当に設定ミスの問題でした。私のすべてのデータベースを削除した後、database.yamlファイルを追加しました。これはconfig.yamlと同じだと思いましたが、明らかにそうではありません。

答えて

1

要求がAuthorizerを通過しない場合、資格情報はnullになります。この場合、基本的なオーソライザが必要になります:

router 
    .route("/register") 
    .pipe(new Authorizer.basic(authServer)) 
    .generate(() => new RegisterController()); 
+0

次にリクエストを変更する必要がありますか?そうでなければ私は401を得ます。 –

+0

何かのような音が誤って設定されていて、それがあなたの他の質問(https://stackoverflow.com/questions/45809125/invalid-client-in-aqueducts-db-and-auth)でも問題を引き起こしています。 -wildfire-example) - config.yamlに間違ったデータベースがあると思います。 Authorizerは、正しく構成されている場合、Authorizationリクエストヘッダーを解析し、資格情報を検証し、Authorizationオブジェクトを作成して要求に添付します。 –

関連する問題