0

我已经在 Exact Online 上注册了两个应用程序(应用程序目标为“测试”),其中一个应用程序的重定向 url 是天蓝色托管站点,另一个是本地托管站点。

具有本地托管站点的应用程序正确授权并成功返回令牌。但是,它无法使用 azure 托管站点授权应用程序。OAuth2 协议版本为 V20。

有人可以帮忙吗?在这种情况下,我们是否需要在 azure 门户上为第三方软件(如 Exact Online)进行 Oauth2 身份验证,以便正确授权请求?

提前致谢。

代码示例:

区域授权请求

     private static readonly ExactOnlineOAuthClient OAuthClient = new ExactOnlineOAuthClient();
     private Boolean AuthorizeClient()
    {
        OAuthClient.Authorize(returnUri);
        return (OAuthClient.Authorization != null);
    }
    #endregion
    
    #region ExactOnlineOAuthClient Class
    public ExactOnlineOAuthClient()
        : base(CreateAuthorizationServerDescription(), ClientIdentifier(), ClientSecret())
    {
        ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ClientSecret());
    }

   
     private static AuthorizationServerDescription CreateAuthorizationServerDescription()
    {
        var baseUri = "https://start.exactonline.nl";
        var uri = new Uri(baseUri.EndsWith("/") ? baseUri : baseUri + "/");
        var serverDescription = new AuthorizationServerDescription
        {
            AuthorizationEndpoint = new Uri(uri, "api/oauth2/auth"),
            TokenEndpoint = new Uri(uri, "api/oauth2/token")
        };

        return serverDescription;
    }
    private static string ClientIdentifier()
    {
        return "ClientIdentifier"; //valid client id
    }
    
    private static string ClientSecret()
    {
        return "ClientSecret"; //valid client secret
    }
    
    private void Authorize(Uri returnUri)
    {
        try
        {
            if (Authorization == null)
            {
                Authorization = ProcessUserAuthorization();
                if (Authorization == null)
                {
                    // Kick off authorization request
                    RequestUserAuthorization(null, returnUri);
                }
            }
            else
            {
                if (AccessTokenHasToBeRefreshed())
                {
                    RefreshAuthorization(Authorization);
                }
            }
        }
        catch(Exception ex)
        {

        }
    }
    #endregion
4

0 回答 0