如何从 Aqueduct 服务器获取刷新令牌

How to get a refresh token from an Aqueduct server

Aqueduct 文档说服务器应该 return 刷新令牌。它应该是这样的:

{
  "access_token" : "Abca09zzzza2o2kelmzlli3ijlka",
  "token_type" : "bearer",
  "refresh_token" : "lkmLIAmooa898nm20jannnnnxaww",
  "expire_in" : 3600
}

但这是服务器实际给出的:

{
    "access_token": "uArVqRgpGKv98aNJpziSmTQiFaX2Ebrz",
    "token_type": "bearer",
    "expires_in": 86399
}

没有refresh_token.

这是我的控制器的样子:

class DemoChannel extends ApplicationChannel {
  ManagedContext context;
  AuthServer authServer;

  @override
  Future prepare() async {
    logger.onRecord.listen((rec) => print("$rec ${rec.error ?? ""} ${rec.stackTrace ?? ""}"));

    final config = WordConfig(options.configurationFilePath);
    final dataModel = ManagedDataModel.fromCurrentMirrorSystem();
    final persistentStore = PostgreSQLPersistentStore.fromConnectionInfo(
        config.database.username,
        config.database.password,
        config.database.host,
        config.database.port,
        config.database.databaseName);

    context = ManagedContext(dataModel, persistentStore);

    final authStorage = ManagedAuthDelegate<User>(context);
    authServer = AuthServer(authStorage);
  }

  @override
  Controller get entryPoint {
    final router = Router();

    router
        .route('/register')
        .link(() => RegisterController(context, authServer));

    router
        .route('/auth/token')
        .link(() => AuthController(authServer));

    router
        .route('/words/[:id]')
        .link(() => Authorizer.bearer(authServer))
        .link(() => WordsController(context));

    return router;
  }
}

我的 AuthController 只是 Aqueduct 附带的标准版。我什至在源代码中都没有看到任何需要调整的参数。

如何让服务器发回刷新令牌?

听起来您正在验证 public OAuth 2 客户端。按照规则,public 客户端不能有刷新令牌。您必须使用机密客户端。当客户有秘密时,它就是机密的。创建客户端时使用 —secret 选项。