bitmark-inc / spring

SPRING: Your Facebook Escape Hatch.
2 stars 0 forks source link

Personal API #63

Closed ritawu91 closed 4 years ago

ritawu91 commented 4 years ago

As a more advanced user, I’d like API access to personal data so I can read/write this data from my own programs.

Acceptance criteria

Design: turn on API> see a list of instructions

Estimation: 2

lemonlatte commented 4 years ago

To support this feature, there are two APIs introduced. One is to create a backend user with a token attached. The user can not log into our system. A user will interact with our API service by the token. Another API is to reset token when the existing token is not secured.

User API

Create new user

This API will create a user and return with an API token. A user can use this token to access backend API.

POST /api/v1/users/

Request

Parameters

Key Value
username string

Example

curl -X POST 'https://127.0.0.1:9111/api/v1/users/' \ 
   --header 'Content-Type: application/json' \
   --header 'Authorization: Token my_token' \
   -d '{"username": "bitmark_account"}'

Response

{"username":"bitmark_account","auth_token":"216d3d849ad9902626a81f769ad9564bcb028a31"}

Reset token

Reset and generate a new token

POST /api/v1/users/<user_id>/reset_token/

Request

Example

curl -X POST 'https://127.0.0.1:9111/api/v1/users/bitmark_account/reset_token/' \ 
   --header 'Content-Type: application/json' \
   --header 'Authorization: Token my_token'

Response

{"auth_token":"216d3d849ad9902626a81f769ad9564bcb028a31"}
thuyenBitmark commented 4 years ago

Hi @lemonlatte , Here is the folder that contains all APIs iOS is calling: https://github.com/bitmark-inc/spring-ios/tree/master/Spring/Services

In specific folder, the file <*>API.swift will define:

Hope it can help. please ping me if anything you need my help :)