Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

missing auth() api call? #5

Open
paranic opened this issue Jul 31, 2017 · 3 comments
Open

missing auth() api call? #5

paranic opened this issue Jul 31, 2017 · 3 comments

Comments

@paranic
Copy link

paranic commented Jul 31, 2017

maybe an auth() function sould be implemented in order to get token?

@WolframHempel
Copy link
Member

WolframHempel commented Jul 31, 2017

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)

@paranic
Copy link
Author

paranic commented Jul 31, 2017

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.

@autimagic
Copy link

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 :-)

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

No branches or pull requests

3 participants