Search code examples
iosswiftauthenticationaccess-token

Login with token authentication SWIFT


I get confused how to make a login session with token authentication? I already have the token authentication but still confuse how to implement that for calling the API. If you guys have some recommendation, please help me.


Solution

  • Usually the flow is the following

    • You call your "login" method in the API with your credentials
    • The API gives back a token string
    • You save that token to a database or keychain or somewhere else
    • On your following calls (getDataFromAPI) you include this token in your request header via the method which is required in your API For example ["Authorization: "yourTokenString"] or ["Authorization: "bearer (yourTokenString)"] or in a parameter dictionary if it is JSON RPC