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

Bad Request in stevenmaguire\oauth2-microsoft\src\Provider\Microsoft.php:79

Open laurelBE opened this issue 6 years ago • 3 comments

how to use provider, currently my code is as follows

$provider = new \Stevenmaguire\OAuth2\Client\Provider\Microsoft([ 'clientId' => $clientId, 'clientSecret' => $clientSecret, 'redirectUri' => 'none', ]);

It gives error as below

#0 C:\inetpub\wwwroot\bephpforTteam\New\vendor\league\oauth2-client\src\Provider\AbstractProvider.php(613):
Stevenmaguire\OAuth2\Client\Provider\Microsoft->checkResponse(Object(GuzzleHttp\Psr7\Response), Array)

laurelBE avatar Apr 18 '18 03:04 laurelBE

Up

simon511000 avatar Aug 23 '18 13:08 simon511000

Well, the redirectUri is important; if it doesn't match a/the callback on the Microsoft app side of things, the request will get rejected. It's essentially used to make sure that the OAuth2 request will end up going to a known URL instead of an arbitrary one, since there will be sensitive data in the URL.

For more information: https://www.oauth.com/oauth2-servers/redirect-uris/

chrisforrence avatar Aug 27 '18 18:08 chrisforrence

Gostaria de contribuir,

Caso não tenha conta empresarial da microsoft, essa rotina funciona com contas de emails comuns usando o login live.com:

$provider = new Stevenmaguire\OAuth2\Client\Provider\Microsoft([ // Required 'clientId' => '{seu cliente-id na conta da Azure.', 'clientSecret' => 'seu cliente-secret gerado na Azure', 'redirectUri' => 'seu link de retorno, deve estar idêntico à conta da 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 as definições de sua aplicação na conta da Azure em: https://portal.azure.com/#home Localize -> Serviços de aplicativos ->Gerenciar o Azure Active Diretory Localize -> Registros de Aplicativos na barra lateral. Crie seu novo registro de aplicativo, client-id, client-secret, permitir tokens de acesso, etc.

ander1980 avatar Jan 19 '20 01:01 ander1980