File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments