jc21 / plex-api

PHP API for Plex Servers
Other
35 stars 8 forks source link

Allow setting of the token directly #3

Closed lhilton closed 6 years ago

lhilton commented 6 years ago

In my use case, I do not wish to store the username/password permanently. I would rather store the token. My workflow looks like this:

$client = new jc21\PlexApi('my.plex.server', '443', true);
$client->setAuth('xxxxxxx', 'xxxxxxx');
$token = $client->getToken();

My application will then store the token for later use. When I need to use the API, I would use it this way:

$token = MyORMThing\Config::where('key', 'plex-token')->first()->pluck('value');
$client = new jc21\PlexApi('my.plex.server', '443', true);
$client->setToken($token);
return $client->getOnDeck();

I'll submit a PR implementing this. Let me know if you would prefer to handle this differently.

jc21 commented 6 years ago

No problems here. I only wrote this thing so I could trigger library updates for my server after I put new files on it. Happy to extend it for other uses.

lhilton commented 6 years ago

Thanks. It's a super clean implementation. I usually fight with these things quite a bit to bootstrap them, but this was working in my test case within a few minutes.

I'm baking it into another project I'm working on, a php / laravel / vuejs project that works similar to OMBI.