Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to get token when login success?

Discussion in 'Scripting' started by chengwang2077, Sep 12, 2020.

  1. chengwang2077

    chengwang2077

    Joined:
    Nov 23, 2019
    Posts:
    131
    I am using Spring Security on the backend. Now I post a login request, and the login is successful, but I still cannot access those services that need to be logged in to access. It seems that the client should get a token when I log in successfully, and then later You have to bring this token with every request, but I don’t know how to do it, and the token is not returned to the client when the login is successful.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    I recommend starting with debugging your usage of the service first.

    Use
    curl
    or
    postman
    to figure out how to call the service and see what comes back.

    Once you understand that it will be far easier to reason about making Unity do that.
     
  3. Zer0Cool

    Zer0Cool

    Joined:
    Oct 24, 2014
    Posts:
    203
    1)
    Normally the token should be returned by the server http response as html or xml entry (soap message).
    In most services this entry is defined by the wsdl interface of the service.

    2)
    Same as a soap request but here you do a JSON request and get a JSON response and JSON token.
    Here you probably you will not get a direct response, but the server sends you a post or get redirect! So your client will be called by a get or post request which holds the JSON web token.
     
    Last edited: Sep 12, 2020