Skip to content

Commit 91ee114

Browse files
docs: add portal login docs (#16)
Co-authored-by: Sagar Batchu <sagar.batchu92@gmail.com>
1 parent 8302be6 commit 91ee114

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docs/micronaut.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,37 @@ public String getSpeakeasyEmbedAccessToken(@RequestAttribute(SpeakeasyMiddleware
200200
String embedAccessToken=controller.getEmbedAccessToken(filterBuilder.build());
201201

202202
// build response
203-
}
203+
}
204+
```
205+
206+
## Portal Login Access Tokens
207+
208+
The Speakeasy SDK can generate access tokens for
209+
our [Developer Portals](https://docs.speakeasyapi.dev/docs/using-speakeasy/build-dev-portals/intro)
210+
that allows your end users to login to your portal and self service logs, usage and api keys.
211+
212+
Below are some examples on how to generate access tokens:
213+
214+
```java
215+
@Get("/portal_login_token")
216+
public String getPortalLoginAccessToken(@RequestAttribute(SpeakeasyMiddlewareController.Key) SpeakeasyMiddlewareController controller){
217+
String customerId="some-customer-id";
218+
219+
// Restrict data by time (last 24 hours)
220+
Instant startTime=Instant.now().minusSeconds(60*60*24);
221+
filterBuilder.withTimeFilter(startTime,SpeakeasyAccessTokenFilterOperator.GreaterThan);
222+
223+
// Populate with any custom claims you want added to the access token
224+
Map<String, String> jwtCustomClaims = new HashMap<>();
225+
226+
// Populate with any permissions you want enabled/disabled for the user
227+
Map<String, Boolean> permissions = new HashMap<>();
228+
229+
String accessToken=controller.getPortalLoginToken(customerId, "some display name", jwtCustomClaims,
230+
permissions, filterBuilder.build());
231+
232+
// build response
233+
}
204234
```
205235

206236
## Setting up for Tests

0 commit comments

Comments
 (0)