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:
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?
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?
0
Comments
-
The whole code snippet - https://gist.github.com/rjkz808/86fe497ce134244bd4e82fc24881a6580
-
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.
0 -
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 server0
-
checking with the team0
-
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?2 -
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 supported0
-
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.0
-
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.0