gpt4 book ai didi

com.github.robozonky.api.remote.entities.ZonkyApiToken.getAccessToken()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 05:53:31 27 4
gpt4 key购买 nike

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

ZonkyApiToken.getAccessToken介绍

暂无

代码示例

代码示例来源:origin: RoboZonky/robozonky

@Override
  public void filter(final ClientRequestContext clientRequestContext) {
    final ZonkyApiToken supplied = token == null ? null : token.get();
    logger.trace("Using token #{}.", supplied);
    final char[] t = supplied == null ? AuthenticatedFilter.EMPTY_TOKEN : supplied.getAccessToken();
    this.setRequestHeader("Authorization", "Bearer " + String.valueOf(t));
    super.filter(clientRequestContext);
  }
}

代码示例来源:origin: com.github.robozonky/robozonky-common

@Override
  public void filter(final ClientRequestContext clientRequestContext) {
    final ZonkyApiToken supplied = token == null ? null : token.get();
    final char[] t = supplied == null ? AuthenticatedFilter.EMPTY_TOKEN : supplied.getAccessToken();
    this.setRequestHeader("Authorization", "Bearer " + String.valueOf(t));
    super.filter(clientRequestContext);
  }
}

代码示例来源:origin: RoboZonky/robozonky

private static InputStream c(final ZonkyApiToken token) {
  final String error = "{\"error\":\"invalid_token\",\"error_description\":\"Invalid access token: "
      + Arrays.toString(token.getAccessToken()) + "\"}";
  return new ByteArrayInputStream(error.getBytes(Defaults.CHARSET));
}

代码示例来源:origin: RoboZonky/robozonky

private static ZonkyApiToken mockToken() {
  final ZonkyApiToken t = mock(ZonkyApiToken.class);
  when(t.getAccessToken()).thenReturn(UUID.randomUUID().toString().toCharArray());
  return t;
}

代码示例来源:origin: RoboZonky/robozonky

@SuppressWarnings({"unchecked", "rawtypes"})
private ApiProvider mockApi(final String username, final char... password) {
  final ApiProvider api = spy(new ApiProvider());
  final ZonkyApiToken token = mock(ZonkyApiToken.class);
  when(token.getAccessToken()).thenReturn(new char[0]);
  final OAuth oauth = mock(OAuth.class);
  when(oauth.login(eq(username), eq(password))).thenReturn(token);
  doAnswer(i -> {
    final Function f = i.getArgument(0);
    return f.apply(oauth);
  }).when(api).oauth(any());
  final Zonky z = mock(Zonky.class);
  doAnswer(i -> {
    final Consumer f = i.getArgument(0);
    f.accept(z);
    return null;
  }).when(api).run(any(Consumer.class), any());
  return api;
}

代码示例来源:origin: RoboZonky/robozonky

@SuppressWarnings({"unchecked", "rawtypes"})
private ApiProvider mockFailingApi() {
  final ApiProvider api = spy(new ApiProvider());
  final ZonkyApiToken token = mock(ZonkyApiToken.class);
  when(token.getAccessToken()).thenReturn(new char[0]);
  final OAuth oauth = mock(OAuth.class);
  when(oauth.login(any(), any())).thenReturn(token);
  doAnswer(i -> {
    final Function f = i.getArgument(0);
    return f.apply(oauth);
  }).when(api).oauth(any());
  final Zonky z = mock(Zonky.class);
  doAnswer(i -> {
    final Consumer f = i.getArgument(0);
    f.accept(z);
    return null;
  }).when(api).run(any(Consumer.class), any());
  doThrow(IllegalStateException.class).when(z).logout(); // last call will fail
  return api;
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void hasToken() throws URISyntaxException {
  final ClientRequestContext crc = mock(ClientRequestContext.class);
  when(crc.getUri()).thenReturn(new URI("http://somewhere"));
  when(crc.getHeaders()).thenReturn(new MultivaluedHashMap<>());
  getTestedFilter().filter(crc);
  assertThat(crc.getHeaders().getFirst("Authorization"))
      .isEqualTo("Bearer " + String.valueOf(AuthenticatedFilterTest.TOKEN.getAccessToken()));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com