Skip to content

Commit

Permalink
Added External Access support
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Jul 4, 2021
1 parent c269197 commit ab5e18a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public IAAuthServiceResponse getIAAuthApp(String id){
return response;
}

public ExternalResourcesResponse getExternalKey(String appId){
return post("/api/v2/oauth2/external/"+appId).object(ExternalResourcesResponse.class);
}

public IAAuthServicePermissionGrantResponse grantIAAuthApp(String id){
IAAuthServicePermissionGrantResponse response = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import de.interaapps.accounts.apiclient.AccountsClient;
import de.interaapps.accounts.apiclient.requests.oauth2.OAuth2AccessTokenRequest;
import de.interaapps.accounts.apiclient.requests.oauth2.OAuth2SetEASRequest;
import de.interaapps.accounts.apiclient.responses.ActionResponse;
import de.interaapps.accounts.apiclient.responses.oauth2.ExternalResourcesResponse;
import de.interaapps.accounts.apiclient.responses.oauth2.OAuth2TokenExchangeResponse;
import org.javawebstack.httpclient.HTTPClient;

Expand All @@ -10,7 +13,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class OAuth2Client extends HTTPClient {
private final String clientId;
Expand Down Expand Up @@ -48,6 +50,14 @@ public boolean checkScopes(AuthorizationURLBuilder urlBuilder, List<String> scop
return true;
}

public ActionResponse setExternalAccessURL(String url){
OAuth2SetEASRequest request = new OAuth2SetEASRequest();
request.clientId = clientId;
request.clientSecret = secret;
request.url = url;
return post("/api/v2/oauth2/external").jsonBody(request).object(ActionResponse.class);
}

public OAuth2TokenExchangeResponse exchangeToken(String code){
OAuth2AccessTokenRequest request = new OAuth2AccessTokenRequest();
request.clientId = clientId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.interaapps.accounts.apiclient.requests.oauth2;

import com.google.gson.annotations.SerializedName;

public class OAuth2SetEASRequest {
@SerializedName("client_id")
public String clientId;
@SerializedName("client_secret")
public String clientSecret;
@SerializedName("url")
public String url;
}

0 comments on commit ab5e18a

Please sign in to comment.