oauth2-microsoft
oauth2-microsoft copied to clipboard
Bad Request in stevenmaguire\oauth2-microsoft\src\Provider\Microsoft.php:79
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)
Up
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/
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.