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.