Create an code auto action that's accessible to users and point a button to it. In that code auto action add the necessary PHP to generate their token and store it. Then in the output of the auto action set it to redirect them back to their profile. Example as follows.
Global
Triggers: None
Type: Code
User: Self
Access: All Registered Users
Conditions
Field: cb_token_api
Operator: Is Empty
Action
Method: PHP
Code: (from your other topic)
Code:
global $_CB_framework;
$encryptedValue = new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':a2xdt7zx' ) )->encryptString( (string) \CBLib\Application\Application::MyUser()->getUserId();
$token = rtrim( strtr( $encryptedValue, '+/', '-_' ), '=' );
$user->set( 'cb_token_api', ( $token ) );
$user->store();
Output
Display: Redirect
URL: [cb:url location="profile_view" /]
Now just point a button to that auto actions URL. If they don't have a token it will generate one.