Last post Aug 28, 2014 01:16 AM by Fei Han - MSFT
Aug 26, 2014 02:46 AM|JamesBaldwinson|LINK
Hi All! I have a Forms app using SignalR and Owin OAuth tokens on the server side. The application is logging in and obtaining the token, then adding this to the header of my signalR hub.
hubConnection.Headers.Add("Authorization", "Bearer " + InfoStore.AuthProperties.access_token);
then starts the connection. This is all working fine on Windows Phone client using xamarin forms, but when I try in the IOS client I can the following exception on the hubConnection.Start() method.
"HttpClientHandler.PreAuthenticate is not supported on this platform. Please check HttpClientHandler.SupportsPreAuthenticate() before using HttpClientHandler.PreAuthenticate."
Obviously the message is pretty straight forward, but if the client does not support it, what is the workaround for IOS with SignalR? I have not yet tested with Android. I did find a similar bug which was for Silverlight
Can anyone tell me if this should work or not? Using all the latest bits with webApi out of the box OAuth tokens, web Api on the client to authenticate and then pass the token into the SignalR header. Also this is on the IPhone Simulator if that makes any
Aug 28, 2014 01:16 AM|Fei Han - MSFT|LINK
Thanks for your post.
According to your description and code, firstly, you could refer to this demo which describes how to use SingaIR in IOS.
Secondly, for the error, it seems like the PreAuthenticate is not supported on IOS and SingalR, so you could try to restructure
the HttpClintHandler when you create a new instance, such as the below:
HttpClientHandler handler = new HttpClientHandler()
UseDefaultCredentials = true,
PreAuthenticate = true
Thirdly, you could refer to this tutorial to learn more about
“Authentication and Authorization for SignalR Hubs”.
If you have any question about my reply, please let me know freely.