forrest
forrest copied to clipboard
UserPassword Missing Token Exception?
Hello,
We went from using UserPasswordSoap, to the UserPassword authentication scheme. We have the username, password, and token all set in our environment and have the Forrest configured as:
` /* * Options include WebServer or UserPassword */ 'authentication' => 'UserPassword',
/*
* Enter your credentials
* Username and Password are only necessary for UserPassword flow.
* Likewise, callbackURI is only necessary for WebServer flow.
*/
'credentials' => [
//Required:
'consumerKey' => env('CONSUMER_KEY'),
'consumerSecret' => env('CONSUMER_SECRET'),
'callbackURI' => env('CALLBACK_URI'),
'loginURL' => env('LOGIN_URL'),
// Only required for UserPassword authentication:
'username' => env('SF_USERNAME'),
// Security token might need to be ammended to password unless IP Address is whitelisted
'password' => env('SF_PASSWORD').env('SF_TOKEN'),
],`
However when making a query using forrest we get the following error:
development.ERROR: Create Order Failed. {"input":{"sfValueObjectId":"a1r2f0000..."},"error":"[object] (Omniphx\\Forrest\\Exceptions\\MissingTokenException(code: 0): No token available at /Users/josh.reeter/projects/5.8/greenfield/vendor/omniphx/forrest/src/Omniphx/Forrest/Repositories/TokenRepository.php:55) [stacktrace] #0 /Users/josh.reeter/projects/5.8/greenfield/vendor/omniphx/forrest/src/Omniphx/Forrest/Repositories/TokenRepository.php(41): Omniphx\\Forrest\\Repositories\\TokenRepository->verify() #1 /Users/josh.reeter/projects/5.8/greenfield/vendor/omniphx/forrest/src/Omniphx/Forrest/Repositories/InstanceURLRepository.php(50): Omniphx\\Forrest\\Repositories\\TokenRepository->get() #2 /Users/josh.reeter/projects/5.8/greenfield/vendor/omniphx/forrest/src/Omniphx/Forrest/Client.php(428): Omniphx\\Forrest\\Repositories\\InstanceURLRepository->get() #3 /Users/josh.reeter/projects/5.8/greenfield/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(237): Omniphx\\Forrest\\Client->query('SELECT Valuatio...')
Any ideas why this might be happening? It seems that if a token can't be located then Forrest should reauthenticate?
Additional Info, it seems the InstanceURLRepository is trying to get the instance URL from the token repo when I call the query.
public function get() { if (isset($this->settings['instanceURL']) && !empty($this->settings['instanceURL'])) { return $this->settings['instanceURL']; } else { return $this->tokenRepo->get()['instance_url']; } }
It doesn't seem to be there, thus MissingTokenException.. Not quite sure how to resolve this since the forret config says instanceUrl is optional and not recommended?
Hi @jreeter, can you provide the entire config/.env? (feel free to mask the credentials)