org.springframework.social.connect.Connection.test()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.springframework.social.connect.Connection.test()方法的一些代码示例,展示了Connection.test()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connection.test()方法的具体详情如下:
包路径:org.springframework.social.connect.Connection
类名称:Connection
方法名:test

Connection.test介绍

[英]Test this connection. If false, indicates calls to the #getApi() will fail. Used to proactively test authorization credentials such as an API access token before invoking the service API.
[中]测试此连接。如果为false,则表示对#getApi()的调用将失败。用于在调用服务API之前主动测试授权凭据,如API访问令牌。

代码示例

代码示例来源:origin: FundRequest/platform

@Bean
public Gitter gitter(@Value("${io.fundrequest.notifications.gitter.consumer-key}") final String consumerKey,
           @Value("${io.fundrequest.notifications.gitter.consumer-secret}") final String consumerSecret,
           @Value("${io.fundrequest.notifications.gitter.access-token}") final String accessToken) {
  final Connection<Gitter> gitterConnection = new GitterConnectionFactory(consumerKey, consumerSecret).createConnection(new AccessGrant(accessToken));
  assert gitterConnection.test();
  return gitterConnection.getApi();
}

代码示例来源:origin: io.loli.social/custom-social-core-extension

private void assertNewConnection(Connection<TestFacebookApi> connection) {
  assertEquals("facebook", connection.getKey().getProviderId());
  assertEquals("9", connection.getKey().getProviderUserId());
  assertEquals("Keith Donald", connection.getDisplayName());
  assertEquals("http://facebook.com/keith.donald",
      connection.getProfileUrl());
  assertEquals("http://facebook.com/keith.donald/picture",
      connection.getImageUrl());
  assertTrue(connection.test());
  TestFacebookApi api = connection.getApi();
  assertNotNull(api);
  assertEquals("123456789", api.getAccessToken());
  assertEquals("123456789", connection.createData().getAccessToken());
  assertEquals("987654321", connection.createData().getRefreshToken());
}

相关文章