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

Add global authentication #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

darthmaim
Copy link
Member

@darthmaim darthmaim commented Sep 4, 2016

This PR removes the $apiKey from the specific endpoint implementation. Everything is handled by the AuthenticatedEndpoint trait now. The API key can be set in a parent endpoint and is inherited.

Examples:

// old
$api->account('API_KEY')->achievements()->get();
// new
$api->account()->achievements()->auth('API_KEY')->get()
// or
$api->auth('API_KEY')->account()->achievements()->get()

// old
$api->characters('API_KEY')->inventoryOf('Char Name')->get();
$api->characters('API_KEY')->equipmentOf('Char Name')->get();
$api->guild()->membersOf('API_KEY', 'GUILD_ID');
$api->pvp()->standings('DIFFERENT_API_KEY')->get();
// new
$api->auth('API_KEY');
$api->characters()->inventoryOf('Char Name')->get();
$api->characters()->equipmentOf('Char Name')->get();
$api->guild()->membersOf('GUILD_ID')->get();
$api->pvp()->standings()->auth('DIFFERENT_API_KEY')->get();

This is something that could be merged for version 4.0.0.

This removes the $apiKey from the endpoint implementation. Everything is handled by the AuthenticatedEndpoint trait now. Authentication is inherited.
@darthmaim darthmaim self-assigned this Sep 4, 2016
@FreezyExp
Copy link

FreezyExp commented Oct 22, 2016

instead of breaking all code that uses this api wrapper, with requiring an additional ->auth('API_KEY') which does look very clean, I must say.

let nodes use the auth as a base class, with the apikey as optional.
then you can add a second get that overrides the authkey

this way, nothing is broken and the code still looks clean.

$api->account('API_KEY')->achievements()->get();
$api->account()->achievements()->auth('API_KEY')->get() // or
$api->auth('API_KEY')->account()->achievements()->get()
//add
$api->account()->achievements()->get('API_KEY');

//just like
$api->guild()->membersOf('API_KEY', 'GUILD_ID');

when used in a get, it is temporary for just that call.
when used in account or auth, it is set in the shared session.

@darthmaim darthmaim added this to the 4.0 milestone Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants