oauth2-microsoft icon indicating copy to clipboard operation
oauth2-microsoft copied to clipboard

Added Bearer token types.

Open MattRink opened this issue 7 years ago • 5 comments

Some Microsoft Office/Outlook OAUTH API's use Bearer tokens. I added the ability to specify the authorization type as either Bearer or none, defaulting to none (the current functionality).

MattRink avatar Feb 08 '18 12:02 MattRink

Thanks for the PR! What is the use case for this functionality? Have you found this functionality is required to authorize and receive an access token? Have you found this functionality is required to make authorized requests against non-auth resources?

stevenmaguire avatar Feb 08 '18 14:02 stevenmaguire

Hi, Internally we were using your package to wrap a series of Microsoft OAuth API's, one of them, the Outlook Mail API required the bearer type tokens, so I added it as an option which suited our use case. I thought you may be interested in the addition too.

MattRink avatar Feb 21 '18 21:02 MattRink

Umh, I think it is always needed. I can see here that this Provider is used only for OAuth2 flows, so as getAuthorizationHeaders is used only this way https://github.com/thephpleague/oauth2-client/blob/master/src/Provider/AbstractProvider.php#L837 and token will be present only when fetching user infos, I suspspect that we should only implement

protected function getAuthorizationHeaders($token = null)
{
    return ['Authorization' => 'Bearer ' . $token];
}

Moreover (I'm gonna open a PR), now the endpoint /me to retrieve user infos has to be changed (as old one is deprecated) and new one needs that Bearer Token.

DonCallisto avatar May 14 '20 09:05 DonCallisto

Also response parsing for User should be adapted. Look here

DonCallisto avatar May 14 '20 10:05 DonCallisto

Moreover I'm wondering if could be a better choice to wrap the official SDK and delegate the heavy work to it, with this library to be only a wrapper/bridge/adapter/cohordinator (call it as you prefer) between league library and microsoft SDK. WDYT?

DonCallisto avatar May 14 '20 10:05 DonCallisto