服务器从移动应用程序接收一次性授权码。我需要将其转换为 spring-social 访问令牌并刷新令牌并将它们保存在服务器数据库中以供以后使用。
我当前的代码:
String oneTimeAuthorizationCode= "xxx"; // provided by mobile client
ConnectionData cd = new ConnectionData("google", null, null, null, null, oneTimeAuthorizationCode, null, null, null);
GoogleConnectionFactory googleConnectionFactory = (GoogleConnectionFactory) connectionFactoryLocator.getConnectionFactory("google");
Connection<Google> connection = googleConnectionFactory.createConnection(cd);
// get the google API and work with it
Google google = (Google) connection.getApi();
oneTimeAuthorizationCode 错误,因为 ConnectionData 需要访问令牌而不是一次性授权代码。知道如何让 spring-social-google 将一次性代码交换为访问令牌和刷新令牌吗?