Open LunarDevelopment opened 8 years ago
I had thought this a problem with Session not being written until the browser is used but the following works:
public function __construct()
{
Session::setDefaultDriver('database');
Forrest::authenticate();
Session::put('k','test');
parent::__construct();
dd(Session::all());
}```
outputs
vagrant@scotchbox:/var/www/callboards$ php artisan push:salesforce array:1 [ "k" => "test" ]
Resolved by using "password" instead of "webserver" authentication.
Credit to @jackson-ben
@LunarDevelopment I know this is closed, but I am interested in hearing more about how you finally got this working, as I'm running into the exact same issue.
When I attempt to use Forrest in an all-command workflow, using the "password" authentication method, i get the same error. Seems the session is never created when in cli?
Are you calling Forrest::authenticate();
before you run any other Forrest commands? I think this could have been the problem. Also check that you are not using browser session, i.e cookie.
Yes, I call Forrest::authenticate();
before anything else. My app's session is configured with the 'file' driver, not cookie.
I have a job that is scheduled to run every 5 minutes. I can get it to work as long as I first visit an http route in the browser that makes a Forrest::authenticate();
call. Then I'm good to go for any cli commands for a while, at least until that browser session expires.
As a workaround, perhaps I could trigger that http request from the command itself? Or maybe I just need to reconsider my Forrest config. I'll continue to work at it and report back here any findings in case someone else goes searching.
Have you tried Session::setDefaultDriver('file'); directly before the authenticate method?
Getting the same error. I have a route calling index
function. and the index function has this
public function index() {
Forrest::authenticate();
Forrest::versions();
}
I am getting the same error 'No token available in 'session' storage'
I am using the database
session driver and I can see a session entry created in the sessions table.
Did anyone solve this?
UPDATE: Sorry to bother, just needed to change this:
'authentication' => 'WebServer',
into this:
'authentication' => 'UserPassword',
in the config/forrest.php
file
I'm back to this issue again, authentication is working through browser but not through artisan command.
Per the solution that worked last time my config\firrest.php
is still set to 'authentication'=>'UserPassword',
[GuzzleHttp\Exception\ClientException]
Client error: `POST https://login.salesforce.com/services/oauth2/token` resulted in a `400 Bad Request` response:
{"error":"invalid_grant","error_description":"authentication failure"}
I solved this for myself by changing the config for forrest.storage.type to 'cache' instead of 'session'.
Hello,
I'm trying to implement an artisan command to get data from Salesforce.
The code works in browser with Forrest but when I run
php artisan MYCOMMAND
I get the following:I can see the session tokens in my browser if I run
dd(Session::all());
however running the same code in CLI gets me an empty array. I've tried every type of storage driver and I'm configuring the artisan command to use my preferred driver manually in the constructorSession::setDefaultDriver('database');
Other issues of this nature have been resolved by calling
Forrest::authenticate();
but the following (overkill) constructor of my artisan command still bags me an empty session array and the above error.