setAccessType('offline'); // rest of the code ?>In this example, we have set the access type to "offline" for the Google API client. The refresh token can be obtained using the $client->fetchAccessTokenWithRefreshToken() method. Package/Library: "google/apiclient"