Scala Mohiva play-silhouette-seed 获取社交数据

Scala Mohiva play-silhouette-seed get social data

我正在使用 https://github.com/mohiva/play-silhouette-seed 我想从 VK 获取一些数据,如城市、国家等,但我不知道应该采用哪种方式。如果我可以做这样的事情 https://vk.com/dev/users.get 并接收 JSON ,我应该将其解析为我的用户数据,那就太完美了。

使用 Silhouette,您有两种可能性。

社交资料生成器和解析器

有了它,您可以扩展现有提供程序以获取更多字段并将数据直接构建到您的模型中。

这在 project website 上有详细记录。

注意:VK提供者略有不同method signature for the parse method, because it gets the OAuth2Info passed additionally. With this you can also query the API with the Play WS API directly in the profile parser, if the data isn't already contained in the default API call。 (授权信息肯定也应该传递给其他提供商。我会为此创建一张票)

使用存储的访问令牌

查询API

如果您存储访问令牌 (OAuth2Info),那么您可以使用 Play WS API 查询 API 并将数据合并到您的用户数据中。