External Authentication Question

I've had success deploying and "authenticating"against the MVC app on github, but now I'm developing an api to connect with a user database hosted on parse.com (using Cloud Code with node.js/express.js).
Its difficult to debug the provider when I don't know the structure of the request Photon Cloud is producing.
Does it go by the default route with /jsmith/foo, or does it explicitly use a querystring like ?userName=jsmith&token=foo ?


  • Good to hear you got the basics working.

    Yes, the parameters all go into the querystring. This is true for the default username and token, as well as for the additional key/value pairs you may set up.

    In addition, we got a first version of custom authentication that uses webscript.io to authenticate against parse.com . I will let you know the details in a PM.
  • And yes, the call to your service looks like this:

    The bold part is what the client defines. AuthenticationValues.SetAuthParameters will produce this string but you can directly set any GET parameters you need client side.
  • I'll have to try the webscript.io solution...
    I've spent eight hours bashing rocks together trying every conceivable method to make this work, from ssl to not, to querystring-question-mark to not, with and without the directory / prefix. I changed up the content-type. I set the response body to byte-for-byte match the response from MVC, in the off-chance that whitespace formatting in JSON was relevant. The only thing i've not done is duplicate every response header byte-for-byte. It will not work.


    The only thing this URL does is serve up GET responses full of [code2=javascript]{"ResultCode":1,"Message":null}[/code2] all day, every day.

    And I've got this....
    And I get this.
    Custom Authentication failed (either due to user-input or configuration or AuthParameter string format). Calling: OnCustomAuthenticationFailed()
    PhotonHandler:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:158)
    NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:746)
    NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:801)
    PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:65)

    I give up. :cry:
  • I followed up in a ticket for further help. Please check your email.
  • greenland
    edited November 2016
    Thanks to everybody that helped out (by pointing out that I'm an idiot). I got it working, and this is the node.js running in Parse.
    // Photon Cloud external authentication API
    var express = require&#40;'express'&#41;;
    var app = express&#40;&#41;;
    app.get&#40;'/api/auth', function&#40;req, res&#41; {
        res.set&#40;'Content-Type', 'application/json'&#41;;
        Parse.User.logIn&#40;req.query.username, req.query.token, {
                success: function &#40;&#41; {
                    res.send&#40;{ "ResultCode": 1, "Message": null }&#41;;
                error: function &#40;&#41; {
                    res.send&#40;{ "ResultCode": 2, "Message": "Authentication Failed." }&#41;;
    As you can tell, it is rudimentary at best, but quite functional. I'm posting it as reference in case anybody else wants to try this.
    This might be redundant with the webscript.io solution, but it seems somewhat silly to juggle API calls between three different servers when Parse has the capability to extend it's own API; no REST key or Application ID required (unless desired).
    I don't like the fact that I'm using Parse.User.logIn just to check username/password combonations, since that has quite a bit of other side effects; but I'm not sure if there's any other way to do it.
  • Great you got it working! And thanks for the sample code.

    You can, of course, use the Parse API to do the authentication call and thereby avoid having another "proxy". Totally makes sense. The main reason behind using webscript.io, is using the same proxy-service where you could handle authentication for all desired third-party authentications (Facebook, ...).

    Out of curiosity - what side effects do you mean with the Parse.User.login?
  • I don't know the specifics, but that method creates an authenticated session, when really all it needs to do is check if the password matches.