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

时间:2019-05-19 02:29:37

标签: oauth dart refresh-token aqueduct dart-server

渡槽文档说服务器应该返回刷新令牌。它应该看起来像这样:

{
  "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只是渡槽随附的标准设备。我什至没有在源代码中看到任何要调整的参数。

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

1 个答案:

答案 0 :(得分:1)

听起来您正在验证公共OAuth 2客户端。根据规则,公共客户端不能具有刷新令牌。您必须使用机密客户端。客户端拥有机密信息时将对其保密。创建客户端时,请使用—secret选项。