Open paranic opened 7 years ago
Generally agree - though for performance reasons we'd encourage user's to generate a token once and reuse it from thereon (as opposed to doing auth->token->api call on every request)
yes but it has an expiration time
maybe there should be a cache in mechanism to cache the authentication token on the first use and use it for future requests. how about a simple tmpfile() file on php will work on all systems.
i am sorry i am not aware if the authenticate returns expiration time, if yes it should be written in the tmpfile() also in order to re-authenticate the user.
This can actually be achieved quite easily
In ApiRequest.php change line 21-25 to; public function __construct( $url, $authData ) { $this->url = $url; $this->requestData['authData'] = $authData; $this->requestData['body'] = array(); }
Call it with; $client = new DeepstreamClient('https://url.etc/api', array( 'username' => 'username', 'password' => 'password' ));
And it will check the username and password agains the users.yml. In config.yml you must enable auth with file, of course.
Works fine her - and sorry for the not so great explanation :-)
maybe an auth() function sould be implemented in order to get token?