0

I am trying to check if the user is successfully logged in to Axosoft. The code bellow never throws an error, even if the user provides the wrong credentials.

public void Login(string user, string pwd)
{
    try
    {
        AxoClient.ObtainAccessTokenFromUsernamePassword
        (
            username: user,
            password: pwd,
            scope: ScopeEnum.ReadWrite
        );
    }
    catch (AxosoftAPIException<ErrorResponse> ex)
    {
        ErrorResponse er = new ErrorResponse();
        er.Error = ex.Source;
        er.ErrorDescription = ex.StackTrace;
        er.Message = ex.Message;
        throw new AxosoftAPIException<ErrorResponse>(er);
    }
}
Tassisto
  • 9,877
  • 28
  • 100
  • 157

1 Answers1

0

I found the solution for my problem.

After a login you can get the value of the HasAccessToken in Proxy.

If you successfully logged in it will return true, otherwise it'll return false.

Proxy AxoClient = new Proxy
                {
                    Url = "http://url",
                    ClientId = "ClientId",
                    ClientSecret = "ClientSecret",
                };

AxoClient.ObtainAccessTokenFromUsernamePassword
                (
                    username: user,
                    password: pwd,
                    scope: ScopeEnum.ReadWrite
                );

MessageBox.Show(AxoClient.HasAccessToken);

I hope this will help others.

Tassisto
  • 9,877
  • 28
  • 100
  • 157