stevenmaguire / oauth2-microsoft

Microsoft OAuth 2.0 support for the PHP League's OAuth 2.0 Client
MIT License
68 stars 41 forks source link

Does not work with professional (office 365) accounts #18

Open vicenteribes opened 5 years ago

vicenteribes commented 5 years ago

I have used this plugin in a project, and worked perfect with personal microsoft accounts (free outlook.com accounts) but couldn't work with professional (office 365 accounts)

I have edited /src/Provider/Microsoft.php changing the following lines:

protected $urlAuthorize = 'https://login.microsoftonline.com/common/oauth2/authorize'; protected $urlAccessToken = 'https://login.microsoftonline.com/common/oauth2/token';

and now works with both personal and professional accounts.

Just to inform any other guy with the same issue.

stevenmaguire commented 5 years ago

@vicenteribes thanks for this. If this is a verifiable change (and maintains support for non-O365 microsoft accounts like hotmail/live accounts assuming they are still supported), I am happy to accept a PR with this permanent change, along with updated passing tests.

ander1980 commented 4 years ago

Gostaria de contribuir,

Caso não tenha conta corporativa da Microsoft, essa rotina funciona com contas de e-mails comuns usando o login live.com:

$ provider = novo Stevenmaguire \ OAuth2 \ Client \ Provider \ Microsoft ([ // Necessário 'clientId' => '{seu cliente-id na conta do Azure.', 'clientSecret' => 'seu cliente-secreto usando o Azure' , 'redirectUri' => 'seu link de retorno, deve estar idêntico à conta do Azure', 'urlAuthorize' => 'https://login.live.com/oauth20_authorize.srf', 'urlAccessToken' => 'https://login.live.com/oauth20_token.srf', //'urlResourceOwnerDetails' => 'https://login.live.com/' //Deprecated ]); É necessário criar como configurações de aplicativo no Azure: https://portal.azure.com/#home Localize -> Serviços de aplicativos -> Gerenciar o Diretório Ativo do Azure Localize -> Registros de aplicativos na barra lateral. Crie seu novo registro de aplicativo, ID do cliente, segredo do cliente, tokens de acesso de permissão, etc.

Dasc3er commented 4 years ago

@stevenmaguire The solution suggested by @vicenteribes should be correct, as officially published by Microsoft itself: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow

More than that, I just verified the connection with a personal account and with a change on the scope separator this library works.