Fatal Error, Access Token must be

Hello all:

I am new, new to development, new to square. This may be a silly question so forgive me for my ignorance. I keep getting the following error. I am using VS code and have run in my terminal the following co:

set SQUARE_ACCESS_TOKEN={my access token}

I replaced my access token with the one on the developer dashboard under the sandbox option. Yet the following error keeps happening. Am I to set my access token somewhere in the vscode separately? If so, where? What am I missing to make the connection? I feel like I am following the steps in the quickstart guide but to no avail.

I appreciate any help that you can provide on this matter. I feel as though once I am able to establish a connection I will be able to run with this but as of right now, I am pulling my hair out.

Fatal error : Uncaught TypeError: Square\BearerAuthManager::__construct(): Argument #1 ($accessToken) must be of type string, bool given, called in C:\xampp\htdocs\HAFHS\vendor\square\square\src\SquareClient.php on line 120 and defined in C:\xampp\htdocs\HAFHS\vendor\square\square\src\BearerAuthManager.php:21 Stack trace: #0 C:\xampp\htdocs\HAFHS\vendor\square\square\src\SquareClient.php(120): Square\BearerAuthManager->__construct(false) #1 C:\xampp\htdocs\HAFHS\quickstart.php(9): Square\SquareClient->__construct(Array) #2 {main} thrown in C:\xampp\htdocs\HAFHS\vendor\square\square\src\BearerAuthManager.php on line 21

:wave: Welcome! Were you able to install composer in the same directory as the project? :slightly_smiling_face:

Bryan,

Thank you for your question. Yes I was able to install Composer in the same directory of my application. Both the composer.json and composer.lock files are listed within the Explorer window of my project. Within the terminal I ran the "set SQUARE_ACCESS_TOKEN = " with the access token from my application dashboard.

Is there some other location or reason why I would be getting this error that you can think of?

Joshua

I’m not sure why its not working. Your on a Windows device right? :slightly_smiling_face:

Yes, I am using VS Code would that have anything to do with it?

It shouldn’t effect it at all. I’m trying to replicate. :slightly_smiling_face:

We were able to replicate this. If you open command line in VS code, and set SQUARE_ACCESS_TOKEN=yourSandboxAccessToken it should work. :slightly_smiling_face:

Bryan,

Unfortunately, I receive no better results. I am sure that I am missing something here but when placing the set SQUARE_ACCESS_TOKEN="MySandboxAcessToken, it show that there are No Matching Commands. I am using “Ctrl+Shift+P” to bring up the command prompt and enter the command there however it doesn’t recognize it at a viable command. Any help is much appreciated.

Joshua

If you call echo is the access token returned? If it’s not the client isn’t set correctly. :slightly_smiling_face:

Bryan,

I apologize for my ignorance but what do you mean call echo?

Joshua

Joshua,

The “echo” statement is a PHP built-in function. You use it like:

echo “debug output: $variable\n”;

inside your .php file. I’m not 100% sure whether the other Bryan was suggesting you type that line into a VScode command prompt or into the file, either way it will probably need a closing double quote mark, just in case that helps!

Cheers,

Brian

Thanks Brian, yes we need to see if the client is set correctly so VScode command prompt to see if the client is set is what we recommend. :slightly_smiling_face: