输入凭据后,Azure AD OAuth2会重定向回Microsoft登录

时间:2017-05-26 12:46:54

标签: php azure oauth-2.0 azure-active-directory

我正在使用oauth2-azure

重定向到登录页面https://login.microsoftonline.com/login.srf后,以下模式循环:

  1. 输入凭据并登录
  2. 页面重定向到http://example.org(没有任何GET参数)
  3. 转到1
  4. 问题是,为什么它没有重定向到use TheNetworg\OAuth2\Client\Provider\Azure; // ... $clientId = "xxx"; $clientSecret = "yyy"; $redirectUri = "http://example.org"; $provider = new Azure(array ( "clientId" => $clientId, "clientSecret" => $clientSecret, "redirectUri" => $redirectUri )); if (!isset($_GET["code"])) { $authUrl = $provider->getAuthorizationUrl(); $_SESSION["oauth2state"] = $provider->getState(); header("location: $authUrl"); die(); } // Validate state, get access token etc... ?为什么要继续重定向到登录表单?页面上没有错误。

    代码:

    Sub Test_EMail()
        If ExitAll = False Then
            Dim OApp As Object, OMail As Object, signature As String
            Set OApp = CreateObject("Outlook.Application")
            Set OMail = OApp.CreateItem(0)
                With OMail
                .Display
                End With
                signature = OMail.HTMLbody
                With OMail
                .To = "test@test.de"
                .Subject = "test"
                .HTMLbody = "<p> Hello </p>" _
                & vbCr & "<p> I want to have a specific line hight because this </p>" _
                & vbCr & "<p> line height is too much space </p>" _
                & vbCr & "<p> How I can decrease this line height? </p>"
                End With
            Set OMail = Nothing
            Set OApp = Nothing
        Else
        End If
    End Sub
    

1 个答案:

答案 0 :(得分:1)

我可以通过设置common和微软帐户登录来重现您的问题:

https://login.microsoftonline.com/common/oauth2/authorize?client_id=xxxxxx&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A16468%2F&scope=openid

在azure ad 1.0中,我们可以在租户中添加微软帐户作为外部用户,当我们在多租户环境中使用common微软帐户登录时,身份提供商无法知道您想要哪个租户微软帐户登录。要解决该问题,您可以使用特定租户:

https://login.microsoftonline.com/YourTenant/oauth2/authorize?client_id=xxxxxx&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A16468%2F&scope=openid

或使用Azure AD V2.0:https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-appmodel-v2-overview