How API auth is working ?

How API auth is working ?

Hello,

I'm trying to have API working inside my symfony project.
I've been struggling a bit but now I'm able to display current user - this is the first step.

My question is about auth.

For now what I did is :

- Generate self-authorized grant and refresh token from developerconsole
- Copy grant token for backup
- I generated refresh token by making a POST request with the URL below

https://accounts.zoho.com/oauth/v2/token?code={grant_token}&redirect_uri={redirect_uri}&client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code

- I copied the values of these tokens inside variables (as well as for my client_id, client_secret, etc) and I inserted those variables inside the configuration array like this :

$configuration=array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri,
'currentUserEmail' => $current_user_email,
'persistence_handler_class' => 'ZohoOAuthPersistenceHandler',
'db_name' => 'subsman',
'db_username' => 'root',
'db_password' => 'HiTdwXFvd3g%PW',
);

- And then I ran this :

ZCRMRestClient::initialize($configuration);
$oAuthClient = \zcrmsdk\oauth\ZohoOAuth::getClientInstance();
$userIdentifier = $current_user_email;
$oAuthTokens = $oAuthClient->generateAccessTokenFromRefreshToken($refreshToken,$userIdentifier);

All of this is inside the constructor of the class RestC.
So it gets executed when I do this :

$obj = new RestC();

And then I intend to call some method to display current user or other stuff, like this :

$obj->getCurrentUser();

My question is : do I have to call the method generateAccessTokenFromRefreshToken each time ?
Other question : now the refresh token is inside the code as a string, but it's also stored inside the database. 
So do I have to keep it as a string or can i just retrieve it from db ?

Thanks for your help.