Skip to content

clients/v1: add service access token methods #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2025
Merged

clients/v1: add service access token methods #93

merged 4 commits into from
May 27, 2025

Conversation

jac
Copy link
Member

@jac jac commented May 27, 2025

Adds the RPC wrapper methods for the Service Access Token create/list/revoke RPCs.

Updates the introspect wrapper to also return UserID.

Part of CORE-980

Test plan

Ran locally

create

(*sams.CreateServiceAccessTokenResponse)(0x140004000f0)({
 Token: (*clientsv1.ServiceAccessToken)(0x1400040a360)(id:"ca16cf7e-f011-4690-b335-a3c9c028db2c" service:"analytics" scopes:"analytics::analytics::read" user_id:"0196aa9f-a46c-7589-91e0-5bb9e13960e9" display_name:"dev-token"),
 Secret: (string) (len=95) "sams_at_bdoFwJDN_-c-814WR2RERm4UghVnLMhdNCiQUYsC1Uo.xqDS_dq3BRnrWdacWEsSD7zFa0SQ5YEtfRQX8mT_zYE"
})

list

([]*clientsv1.ServiceAccessToken) (len=1 cap=1) {
 (*clientsv1.ServiceAccessToken)(0x140001b2360)(id:"ca16cf7e-f011-4690-b335-a3c9c028db2c" service:"analytics" scopes:"analytics::analytics::read" user_id:"0196aa9f-a46c-7589-91e0-5bb9e13960e9" display_name:"dev-token")
}

introspect

(*sams.IntrospectTokenResponse)(0x140003ce0c0)({
 Active: (bool) true,
 Scopes: (scopes.Scopes) (len=1 cap=1) {
  (scopes.Scope) (len=26) "analytics::analytics::read"
 },
 ClientID: (string) (len=45) "sams_cid_01970868-ae38-7ad1-82a0-73ddacaba597",
 ExpiresAt: (time.Time) 1970-01-01 00:00:00 +0000 UTC, // zero value as no expiry
 UserID: (string) (len=36) "0196aa9f-a46c-7589-91e0-5bb9e13960e9"
})

revoke
doesn't have a response value so here is the result of introspect again for the revoked token

(*sams.IntrospectTokenResponse)(0x140003ce0c0)({
 Active: (bool) false,
 Scopes: (scopes.Scopes) {
 },
 ClientID: (string) "",
 ExpiresAt: (time.Time) 1970-01-01 00:00:00 +0000 UTC,
 UserID: (string) ""
})

@jac jac requested a review from a team as a code owner May 27, 2025 11:09
jac and others added 2 commits May 27, 2025 18:29
@jac jac enabled auto-merge (squash) May 27, 2025 17:31
@jac jac merged commit 6ebcb44 into main May 27, 2025
2 checks passed
@jac jac deleted the jac/core-980 branch May 27, 2025 17:35
option (sams_required_scopes) = "sams::service_access_token::write";
option (sams_required_scopes) = "sams::service_access_tokens::write";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings are now all outdated 😁 assuming this is an intended change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants