Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c1aba6
Merge pull request #179 from contentstack/master
reeshika-h Aug 26, 2025
b86918e
Merge pull request #180 from contentstack/staging
harshithad0703 Aug 26, 2025
4c9f6fe
Add OAuth implementation for testing
reeshika-h Aug 26, 2025
b5ef724
fix: Generate state parameter in constructor for OAuth security
reeshika-h Aug 26, 2025
9544846
fix: Update OAuth implementation
reeshika-h Aug 28, 2025
c0d614d
fix: Update OAuth implementation 1
reeshika-h Aug 28, 2025
d283ea6
fix: Update OAuth implementation 2
reeshika-h Aug 28, 2025
9256fa0
fix: Update OAuth implementation 3
reeshika-h Aug 28, 2025
99ca31f
fix: Update OAuth implementation 4
reeshika-h Aug 28, 2025
4c89089
fix: Update OAuth implementation 5
reeshika-h Aug 28, 2025
258fa67
fix: Update OAuth implementation 6
reeshika-h Aug 29, 2025
b0c5f10
fix: Update OAuth implementation 7
reeshika-h Aug 29, 2025
a02f161
fix: Update OAuth implementation 8
reeshika-h Aug 29, 2025
2644266
fix: Update OAuth implementation 9
reeshika-h Aug 29, 2025
f688b3d
fix: Refactor OAuth handling and improve token management
reeshika-h Aug 29, 2025
f7ae51f
chore: Release version 1.8.0 with OAuth 2.0 support and code improvem…
reeshika-h Sep 3, 2025
10383cd
refactor: Move OAuth error messages to constants and clean up imports
reeshika-h Sep 3, 2025
96403b1
fix: Update OAuth host handling to support for regions
reeshika-h Sep 9, 2025
75a6b1e
feat: Implement token storage via TokenCallback interface
reeshika-h Sep 9, 2025
0c04e34
fix: Ensure default host is properly used in OAuth config
reeshika-h Sep 9, 2025
b5feb78
Merge pull request #181 from contentstack/feat/DX-3345-OAuth-impl
reeshika-h Sep 10, 2025
87317f0
refactor: Simplify OAuth configuration methods and enhance PKCE flow …
reeshika-h Sep 15, 2025
3d91e99
refactor: Update OAuth configuration methods to enhance clarity and s…
reeshika-h Sep 15, 2025
2353b18
Merge pull request #184 from contentstack/fix/oauth-impl
reeshika-h Sep 15, 2025
b447de8
Merge pull request #182 from contentstack/development
harshithad0703 Sep 17, 2025
209d8bb
Merge pull request #186 from contentstack/master
harshithad0703 Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Update OAuth implementation 4
  • Loading branch information
reeshika-h committed Aug 28, 2025
commit 99ca31fcd7fccbe53ff6b694be9eff3ca5ea7801
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public String getTokenEndpoint() {
.replaceAll("^dev\\d+", "dev") // Replace dev1, dev2, etc. with dev
.replace("io", "com");

return "https://" + hostname;
return "https://" + hostname + "/apps/oauth/token";
}

/**
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/com/contentstack/cms/oauth/OAuthHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public String authorize() {

StringBuilder urlBuilder = new StringBuilder(baseUrl);
urlBuilder.append("?response_type=").append(config.getResponseType())
.append("&client_id=").append(URLEncoder.encode(config.getClientId(), "UTF-8"));
.append("&client_id=").append(URLEncoder.encode(config.getClientId(), "UTF-8"))
.append("&redirect_uri=").append(URLEncoder.encode(config.getRedirectUri(), "UTF-8"));

if (config.getClientSecret() != null && !config.getClientSecret().trim().isEmpty()) {
return urlBuilder.toString();
Expand Down Expand Up @@ -216,18 +217,30 @@ public CompletableFuture<OAuthTokens> refreshAccessToken() {
* Executes a token request and processes the response
*/
private OAuthTokens executeTokenRequest(Request request) throws IOException {
System.out.println("\nToken Request Details:");
System.out.println("URL: " + request.url());
System.out.println("Method: " + request.method());
System.out.println("Headers: " + request.headers());

Response response = null;
ResponseBody responseBody = null;
try {
response = httpClient.newCall(request).execute();
responseBody = response.body();

System.out.println("\nToken Response Details:");
System.out.println("Status Code: " + response.code());
System.out.println("Headers: " + response.headers());

if (!response.isSuccessful()) {
String error = responseBody != null ? responseBody.string() : "Unknown error";
throw new RuntimeException("Token request failed: " + error);
System.err.println("Error Response Body: " + error);
throw new RuntimeException("Token request failed with status " + response.code() + ": " + error);
}

String body = responseBody != null ? responseBody.string() : "{}";
System.out.println("Success Response Body: " + body);

OAuthTokens newTokens = gson.fromJson(body, OAuthTokens.class);

// Keep old refresh token if new one not provided
Expand Down