Photon Chat JavaScript SDK custom authentication

I have a free plan chat app registered in Photon dashboard. I want to use custom authentication service. And when I try to authenticate with an object:

const type = Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom;
chatClient.setCustomAuthentication('', type, {
 '(string)message': 'some_data',
 '(string)signature': 'some_other_data'
});

Photon SDK gives me this error:

Client: Error: 3101 NameServer authentication failed: 32755 Authentication data type not supported

When I send regular string (or JSON object string) I don't see any errors related to data format. But this data is not being passed in request body to my server (POST request works itself). Photon chat SDK says, that I can provide raw JS object and it will get passed in `application/json` format when sending POST request to the authentication endpoint. Can you help me with this issue?

Comments

  • Hi @rjkz808,

    Thank you for choosing Photon!

    It looks like JSON object as custom authentication payload is not fully supported yet or broken in JavaScript SDK.
    We will investigate and see if this will be fixed.
    This could take time as it may require some server-side adjustments.

    If you can get around this by using stringified JSON string it would unblock the situation for you.
    If this is not possible let us know.
  • rjkz808rjkz808
    edited December 2019
    Hi! I figured out that parameters for authentication provider can only be passed in URL query. Stringified JSON is not being added to request body when I receive it on my web server
  • Hi @rjkz808,

    Maybe there is an issue with the JavaScript/TypeScript implementation but the API supports HTTP POST with payload. It just needs to be not null nor empty.
  • JohnTube said:

    Hi @rjkz808,

    Maybe there is an issue with the JavaScript/TypeScript implementation but the API supports HTTP POST with payload. It just needs to be not null nor empty.

    So, will it be fixed in JavaScript/TypeScript SDK?
  • checking with the team
  • vadimvadim ✭✭✭
    JSON object as custom authentication payload is not supported on js server side currently. This is unlikely to be fixed soon..
    Can you please use string instead?
  • Yes, I use query strings for this purpose at the moment. I think this feature should be removed from SDK until it'll be fully supported
  • Will2XWill2X
    edited May 2
    Is there any update on this? I have tried using a string as POST authData and it is not being relayed to the web server. authParameters come through in the query string though.
  • Will2XWill2X
    edited May 6
    A work-around for this issue is to use pass-thru authentication with a 1-time, time-limited, key; sending the pass-thru data in authParameters (GET/query string). It complicates the process a bit but prevents vital auth data from being exploited via server logs since it will have already been used, or expired.

    This process should probably be used anyways, instead of trusting hosted Photon with crucial data.
Sign In or Register to comment.