Skip to content

Commit 4c89089

Browse files
committed
fix: Update OAuth implementation 5
1 parent 99ca31f commit 4c89089

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/main/java/com/contentstack/cms/models/OAuthConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public String getTokenEndpoint() {
9494
.replaceAll("^dev\\d+", "dev") // Replace dev1, dev2, etc. with dev
9595
.replace("io", "com");
9696

97-
return "https://" + hostname + "/apps/oauth/token";
97+
return "https://" + hostname + "/token";
9898
}
9999

100100
/**

src/main/java/com/contentstack/cms/oauth/OAuthHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public OAuthHandler(OkHttpClient httpClient, OAuthConfig config) {
6565
*/
6666
private Request.Builder _getHeaders() {
6767
return new Request.Builder()
68-
.header("Content-Type", "application/x-www-form-urlencoded");
68+
.header("Content-Type", "application/x-www-form-urlencoded")
69+
.header("authorization", "Bearer " + (tokens != null ? tokens.getAccessToken() : ""));
6970
}
7071

7172
/**
@@ -150,7 +151,8 @@ public CompletableFuture<OAuthTokens> exchangeCodeForToken(String code) {
150151
.add("grant_type", "authorization_code")
151152
.add("code", code)
152153
.add("redirect_uri", config.getRedirectUri())
153-
.add("client_id", config.getClientId());
154+
.add("client_id", config.getClientId())
155+
.add("app_id", config.getAppId());
154156

155157
// Choose between client_secret and code_verifier like JS SDK
156158
if (config.getClientSecret() != null) {

0 commit comments

Comments
 (0)