How to permanently authorize my application? Do I always need to use a new authorization code?
I want to make a bot that comments and likes videos. I can do it but I always need to visit a URL to authorize the application for each video. How to permanently authorize?

Use the following code to get a refresh_token upon the initial request.
$client = new Google_Client([
'access_type' => 'offline'
]);
You will only get a refresh token once so if your app already has access to your Google account you will need to revoke it at your security settings on https://myaccount.google.com/.
@ricardoreis Don't forget to add promt: 'consent' to the client to get the refresh token
You can actually initiate your own instance of the Credentials class, then pass as parameters the token, refresh_token, client_id, and client_secret.
from google.oauth2.credentials import Credentials