API access on behalf of your clients (web flow) can't refresh properly
I'm using the API Access on behalf of my clients web flow and I am able to successfully pull the example code CampaignService in the example. The only thing I can't figure out is that the State is still in the URL after being redirected and that when I refresh, the web page breaks and the token never gets reused.
I have the oauth code placed above the html tag to get the refresh token and then it pulls up the page, but I can't figure out how to save the token properly.
Have you tried these steps yet?
I have that piece of code already. I wasn't sure what to replace with the "..." though. On the page that is running this, I'm requiring both the autoload file and this new oauth2 instance.
So could you share your code snippet here then? Thanks.

So, could you clarify what's the purpose of your app? Do you want to use refresh token (so you don't need to ask your user to authorize again) or do you want to ask the user to authorize every time?
If the former, then following this guide would be more appropriate.
If the latter, then what you need to do in the else clause is to use our client library to issue requests to the API server, as usual.
For example, you would use $oauth2 to build AdWordsSession:
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oauth2)
->build();
$adWordsServices = new AdWordsServices();
$campaignService = $adWordsServices->get($session, CampaignService::class);
// Make calls using $campaignService.
I'm trying to build out a customized dashboard to show a few SEM modules from AdWords. I would like to have a refresh token be asked once and not every time they refresh the page.
I have the included code that you have from the previous response, is that why I'm being asked every time?
I have an MCC account and I thought the webflow to access on behalf of the client would be the better route. Is this the better webflow for that?
If I use the installed application flow, I get Unauthorized Client Error.
If you want to store the refresh token, then in Step 2.2, you need to use offline instead of online:
$config = [
// Set to 'offline' if you require offline access.
'access_type' => 'offline'
];
Then in step 2.3, you will get $refreshToken for a specific customer account:
$refreshToken = $authToken['refresh_token'];
You need to store that securely, so next time, for the specific customer account, you can use refresh token to issue API requests on behalf of the customer.
Having said that, installed application flow should also work too. I suggest you to review this guide thoroughly.
For the error regarding OAuth2 installed application flow, please reach out to AdWords API Forum.
Closing this due to inactivity.