EJsonConverterNotFound on TUserToken

I get this error when connecting from an application to a Sphinx App:

Project SphinxAuth.exe raised exception class EJsonConverterNotFound with message 'Could not find JSON converter for type "Proxy<System.Generics.Collections.TList<Sphinx.Entities.TUserToken>>"'.

I have Aurelius.Mapping.Attributes in all the appropriate places.
Any ideas?

You didn't provide much detailed info, so I can't understand why your app is trying to serialize a type of TUserToken? Any call stack?

My App creates a Client and then gets an Access Token from the SphinxServer (see below). This is fine.

The error occurs when the client calls the service

FClient.Service.GetUsers(TenantId)

This raises the exception on the Sphinx Server.

function TServerToSphinx.GetClient: TXDataClient;
var lAccessToken: string;
begin
  if not Assigned(FClient) then
  begin
    FClient := TXDataClient.Create();
    FClient.Uri := FServiceURL;
    FClient.HttpClient.OnSendingRequest :=
      procedure(Req: THttpRequest)
      begin
        Req.Headers.SetValue('authorization', 'Bearer ' + GetAccessToken);
      end;
  end;
  Result := FClient;
end;

function TServerToSphinx.GetAccessToken: string;
begin
  if (not Assigned(FTokenResult)) or (FTokenResult.Expiration < Now) then
    AuthoriseServer;

  Result := FTokenResult.AccessToken;
end;

procedure TServerToSphinx.AuthoriseServer;
var
  SphinxLogin: TSphinxLogin;
begin
  FTokenResult := nil;
  SphinxLogin := TSphinxLogin.Create(nil);
  try
    SphinxLogin.Authority := FAuthority;
    SphinxLogin.ClientId := FClientId;
    if not FScopes.Contains('openid') then
      SphinxLogin.Scope := FScopes + IfThen(FScopes.IsEmpty, '', ' ') + 'openid';

    FTokenResult := SphinxLogin.RequestToken(FClientSecret);
  finally
    SphinxLogin.Free;
  end;

I have a second service on that application that works as expected. That service doesn't use the Sphinx Model.

I solved this issue by creating an intermediate object rather than returning the TUser descendant.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.