How to design a RESTful API to check for user's credentials?

后端 未结 5 2131
梦谈多话
梦谈多话 2021-02-13 12:31

I\'m designing an API for a mobile app, and I hope to keep it RESTful.
API\'s are authorized using Basic HTTP Auth, however, When the user open the app for the first time, h

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 13:05

    A good approach is to perform a GET request for the account/profile info of the current user. and have it return the username, settings, avatar url, etc. me is a frequently used as a shorthand identifier of the authenticating user.

    GET https://api.example.com/profiles/me
    HTTP/1.1 200 OK
    {
      "username": "bob",
      "id": "xyz",
      "created_at": 123,
      "image_url": "https://example.com/bob.png"
    }
    

提交回复
热议问题