Generating Private Access Token through console

Hi there, I am having a problem. I am running GitLab containerized, but I need to generate a private access token to use the API for configuring some settings. The problem is that I don’t want to use the UI, because this process needs to be automated, but using the API requires a Personal Access Token. I have tried using the console and giving commands like this:

user = User.where(id: 1).first
token = user.create_personal_access_token
puts token.token

Unfortunately the create_personal_access_token method doesn’t exist anymore, and I can’t find any other way than using the UI.

Does someone from the GitLab forum know how I can achieve API usage right after container creation using a auto-generated or preset Personal Access Token?