Unable to generate oAuthToken

I am trying to add this below code to service method

OAuthTokenIssuer.OAuth2AccessTokenResult tokenResult = oAuthTokenIssuer.issueToken(userLogin,
        messageTools.getDefaultLocale(), Collections.emptyMap());
OAuth2AccessToken accessToken = tokenResult.getAccessToken();

But its not working due to import error in serviceBean

The import com.haulmont.restapi cannot be resolved
The import org.springframework.security cannot be resolved

You’re probably trying to use the OAuthTokenIssuer from the core module, but this bean is not available there. You can use it from the web tier.

Hi all. I am also trying to do something similar:

  • Have public 3rd party web app that allows users to login via REST API
  • Also have internal functions for staff via Generic UI / web module

I am trying to allow staff generate a REST API token from Generic UI for any user, that can be passed to the 3rd party web app, to allow staff to open 3rd party web app already logged in as the selected user.

As you mention, the OAuthTokenIssuer class is available in the web tier, but how do I get access to the runtime instance created by the REST API ?

I can generate tokens via a custom REST controller, as it can inject and get access to the OAuthTokenIssuer bean, but I can’t find a way to call the token issuer from the code for a generic UI … is it possible?