Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserPassword Missing Token Exception? #223

Open
jreeter opened this issue Sep 11, 2019 · 2 comments
Open

UserPassword Missing Token Exception? #223

jreeter opened this issue Sep 11, 2019 · 2 comments

Comments

@jreeter
Copy link

jreeter commented Sep 11, 2019

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?

@jreeter
Copy link
Author

jreeter commented Sep 11, 2019

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?

@omniphx
Copy link
Owner

omniphx commented Nov 23, 2019

Hi @jreeter, can you provide the entire config/.env? (feel free to mask the credentials)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants