Skip to content

Commit

Permalink
[BREAKING CHANGE] Drop authentication related arguments from ChannelA… (
Browse files Browse the repository at this point in the history
#1157)

…ccessTokenClient.

The endpoint is not require authenticaiton informantion.
  • Loading branch information
tokuhirom committed Nov 16, 2023
1 parent da009fb commit 8c33b7d
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ src/main/java/com/linecorp/bot/oauth/model/IssueChannelAccessTokenResponse.java
src/main/java/com/linecorp/bot/oauth/model/IssueShortLivedChannelAccessTokenResponse.java
src/main/java/com/linecorp/bot/oauth/model/IssueStatelessChannelAccessTokenResponse.java
src/main/java/com/linecorp/bot/oauth/model/VerifyChannelAccessTokenResponse.java
src/test/java/com/linecorp/bot/oauth/client/ChannelAccessTokenClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
*/
package com.linecorp.bot.oauth.client;

import com.linecorp.bot.client.base.ApiAuthenticatedClientBuilder;
import com.linecorp.bot.client.base.ApiClientBuilder;
import com.linecorp.bot.client.base.Result;
import com.linecorp.bot.client.base.channel.ChannelTokenSupplier;
import com.linecorp.bot.oauth.model.ChannelAccessTokenKeyIdsResponse;
import com.linecorp.bot.oauth.model.IssueChannelAccessTokenResponse;
import com.linecorp.bot.oauth.model.IssueShortLivedChannelAccessTokenResponse;
Expand Down Expand Up @@ -168,21 +167,10 @@ CompletableFuture<Result<VerifyChannelAccessTokenResponse>> verifyChannelToken(
CompletableFuture<Result<VerifyChannelAccessTokenResponse>> verifyChannelTokenByJWT(
@Query("access_token") String accessToken);

public static ApiAuthenticatedClientBuilder<ChannelAccessTokenClient> builder(
String channelToken) {
return new ApiAuthenticatedClientBuilder<>(
public static ApiClientBuilder<ChannelAccessTokenClient> builder() {
return new ApiClientBuilder<>(
URI.create("https://api.line.me"),
ChannelAccessTokenClient.class,
new ChannelAccessTokenExceptionBuilder(),
channelToken);
}

public static ApiAuthenticatedClientBuilder<ChannelAccessTokenClient> builder(
ChannelTokenSupplier channelTokenSupplier) {
return new ApiAuthenticatedClientBuilder<>(
URI.create("https://api.line.me"),
ChannelAccessTokenClient.class,
new ChannelAccessTokenExceptionBuilder(),
channelTokenSupplier);
new ChannelAccessTokenExceptionBuilder());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setUp() {
wireMockServer.start();
WireMock.configureFor("localhost", wireMockServer.port());

target = ChannelAccessTokenClient.builder("MY_ACCESS_TOKEN")
target = ChannelAccessTokenClient.builder()
.apiEndPoint(URI.create(wireMockServer.baseUrl()))
.build();
}
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions generator/src/main/resources/line-java-codegen/api.pebble
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{# @pebvariable name="package" type="java.lang.String" -#}
{# @pebvariable name="generatorClass" type="java.lang.String" -#}
{# @pebvariable name="classname" type="java.lang.String" -#}
{# @pebvariable name="authenticated" type="java.lang.Boolean" -#}
{# @pebvariable name="authMethods" type="java.util.ArrayList<org.openapitools.codegen.CodegenSecurity>" -#}
{% include "./licenseInfo.pebble" %}
package {{ package }};
{% import "./macros/api_param.pebble" %}
Expand Down Expand Up @@ -71,7 +71,7 @@ public interface {{classname}} {

{% endfor %}

{% if authenticated %}
{% if authMethods != null %}
public static ApiAuthenticatedClientBuilder<{{classname}}> builder(String channelToken) {
return new ApiAuthenticatedClientBuilder<>(URI.create("{{ endpoint(classname) }}"), {{classname}}.class, new {{ exceptionbuilderclassname(classname) }}(), channelToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{# @pebvariable name="operations" type="org.openapitools.codegen.model.OperationMap" -#}
{# @pebvariable name="generatorClass" type="java.lang.String" -#}
{# @pebvariable name="classname" type="java.lang.String" -#}
{# @pebvariable name="authenticated" type="boolean" -#}
{# @pebvariable name="authMethods" type="java.util.ArrayList<org.openapitools.codegen.CodegenSecurity>" -#}
{% include "./licenseInfo.pebble" %}

package {# @pebvariable name="package" type="java.lang.String" -#}{{package}};
Expand Down Expand Up @@ -71,7 +71,7 @@ public class {{classname}}Test {
configureFor("localhost", wireMockServer.port());


api = {{classname}}.builder({% if authenticated %}"MY_OWN_TOKEN"{% endif %})
api = {{classname}}.builder({% if authMethods != null %}"MY_OWN_TOKEN"{% endif %})
.apiEndPoint(URI.create(wireMockServer.baseUrl()))
.build();
}
Expand Down
Loading

0 comments on commit 8c33b7d

Please sign in to comment.