Modify scope in post login action

I’m trying to migrate Rules to Actions. In rule i have following code to modify scope for accesstoken:

context.accessToken.scope = scopes;

Now I’m trying to do similar thing in action
api.accessToken.scope = scopes.

but I’m not allowed.

and using setCustomClaim("scope"), I have following error:

The "scope" claim cannot be set.

How can I set custom scopes obtained?