Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,78 @@ to make working with the API easier, and the `pubsub` module which is a library

### Public vs Secured APIs

For the API client, there are two classes, `DefaultApi` and `PublicApi`. The `DefaultApi` contains methods that take your API key, and `PublicApi` contains api calls
that can be made directly from a browser/mobile device/etc.
For the API client, there are two classes, `DefaultApi` and `PublicApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains api calls
that can be made directly from a browser/mobile device/etc without authentication.

## Quick Start

### Using Authenticated APIs (DefaultApi)

**Important:** You must set your API key on the ApiClient before making authenticated requests. If you don't, requests will fail with a 401 error.

```java
import com.fastcomments.invoker.ApiClient;
import com.fastcomments.invoker.ApiException;
import com.fastcomments.api.DefaultApi;
import com.fastcomments.model.*;

public class Example {
public static void main(String[] args) {
// Create and configure the API client
ApiClient apiClient = new ApiClient();

// REQUIRED: Set your API key (get this from your FastComments dashboard)
apiClient.setApiKey("YOUR_API_KEY_HERE");

// Create the API instance with the configured client
DefaultApi api = new DefaultApi(apiClient);

// Now you can make authenticated API calls
try {
// Example: Add an SSO user
CreateAPISSOUserData userData = new CreateAPISSOUserData();
userData.setId("user-123");
userData.setEmail("user@example.com");
userData.setDisplayName("John Doe");

AddSSOUserAPIResponse response = api.addSSOUser("YOUR_TENANT_ID", userData)
.execute();
System.out.println("User created: " + response);

} catch (ApiException e) {
System.err.println("Error: " + e.getResponseBody());
// Common errors:
// - 401: API key is missing or invalid
// - 400: Request validation failed
}
}
}
```

### Using Public APIs (PublicApi)

Public endpoints don't require authentication:

```java
import com.fastcomments.api.PublicApi;
import com.fastcomments.invoker.ApiException;

PublicApi publicApi = new PublicApi();

try {
var response = publicApi.getCommentsPublic("YOUR_TENANT_ID", "page-url-id")
.execute();
System.out.println(response);
} catch (ApiException e) {
e.printStackTrace();
}
```

### Common Issues

1. **401 "missing-api-key" error**: Make sure you call `apiClient.setApiKey("YOUR_KEY")` before creating the DefaultApi instance.
2. **Wrong API class**: Use `DefaultApi` for server-side authenticated requests, `PublicApi` for client-side/public requests.
3. **Null API key**: The SDK will silently skip authentication if the API key is null, leading to 401 errors.

## Notes

Expand Down
6 changes: 3 additions & 3 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.fastcomments</groupId>
<artifactId>client</artifactId>
<version>0.0.25</version>
<version>0.0.26</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -56,7 +56,7 @@ Add this dependency to your project's build file:
}

dependencies {
implementation "com.fastcomments:client:0.0.25"
implementation "com.fastcomments:client:0.0.26"
}
```

Expand All @@ -70,7 +70,7 @@ mvn clean package

Then manually install the following JARs:

* `target/client-0.0.25.jar`
* `target/client-0.0.26.jar`
* `target/lib/*.jar`

## Getting Started
Expand Down
45 changes: 30 additions & 15 deletions client/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,8 @@ paths:
schema:
$ref: '#/components/schemas/GetSubscriptionsAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
post:
Expand All @@ -2024,7 +2025,8 @@ paths:
schema:
$ref: '#/components/schemas/CreateSubscriptionAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand Down Expand Up @@ -2060,7 +2062,8 @@ paths:
schema:
$ref: '#/components/schemas/DeleteSubscriptionAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
/api/v1/sso-users:
Expand Down Expand Up @@ -2089,7 +2092,8 @@ paths:
schema:
$ref: '#/components/schemas/GetSSOUsers_200_response'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
post:
Expand All @@ -2115,7 +2119,8 @@ paths:
schema:
$ref: '#/components/schemas/AddSSOUserAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand Down Expand Up @@ -2144,7 +2149,8 @@ paths:
schema:
$ref: '#/components/schemas/GetSSOUserByIdAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
/api/v1/sso-users/by-email/{email}:
Expand Down Expand Up @@ -2172,7 +2178,8 @@ paths:
schema:
$ref: '#/components/schemas/GetSSOUserByEmailAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
/api/v1/sso-users/{id}:
Expand Down Expand Up @@ -2214,7 +2221,8 @@ paths:
schema:
$ref: '#/components/schemas/DeleteSSOUserAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
patch:
Expand Down Expand Up @@ -2254,7 +2262,8 @@ paths:
schema:
$ref: '#/components/schemas/PatchSSOUserAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand Down Expand Up @@ -2295,7 +2304,8 @@ paths:
schema:
$ref: '#/components/schemas/PutSSOUserAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand All @@ -2317,7 +2327,8 @@ paths:
schema:
$ref: '#/components/schemas/GetPagesAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
post:
Expand All @@ -2343,7 +2354,8 @@ paths:
schema:
$ref: '#/components/schemas/AddPageAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand Down Expand Up @@ -2372,7 +2384,8 @@ paths:
schema:
$ref: '#/components/schemas/GetPageByURLIdAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
/api/v1/pages/{id}:
Expand Down Expand Up @@ -2400,7 +2413,8 @@ paths:
schema:
$ref: '#/components/schemas/DeletePageAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-accepts:
- application/json
patch:
Expand Down Expand Up @@ -2433,7 +2447,8 @@ paths:
schema:
$ref: '#/components/schemas/PatchPageAPIResponse'
description: Ok
security: []
security:
- api_key: []
x-content-type: application/json
x-accepts:
- application/json
Expand Down
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'

group = 'com.fastcomments'
version = '0.0.25'
version = '0.0.26'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion client/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
settings(
organization := "com.fastcomments",
name := "client",
version := "0.0.25",
version := "0.0.26",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
Expand Down
Loading