rest

package
v0.0.0-...-dae10ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 7 Imported by: 0

README

oToDo API

This package contain apis of oToDo.

All APIs require authentication unless otherwise specified, we are using access_token and refresh_token for authentication. You needs to login to obtain tokens, then include authorization in your Request.Headers:

Authorization: Bearer <access_token>

And safely save refresh_token, e.g.: localStroage

Session

Login

Login with password

POST /api/sessions

Request
Param Type Description
userName String "admin"
password String "admin123"
Response
Param Type Description
accessToken String Json web token
expiresIn Int Access token expiration seconds
tokenType String Only bearer now
refreshToken String Should be save SAFELY
Remark
  • This is a public api
Logout

Logout and unactive refresh token

DELETE /api/sessions

Request
Param Type Description
- - -
Response
Param Type Description
message String "see you"
New Access Token (Active)

Get new access token by refresh token

POST /api/sessions/current/tokens

Request
Param Type Description
refreshToken String From Login
Response
Param Type Description
accessToken String See Login
expiresIn Int See Login
tokenType String See Login
New Access Token (Passive)

POST /api/*

Details

The system may include an new access token in your non-public request, check the response headers if there exists Authorization, you can update your local token so that we dont need to refresh token frequently. The smuggled token still follows your request format:

Authorization: Bearer <access_token>
Test Access Token

Test your access token, also for passsive refresh token via timer

GET /api/sessions

Github OAuth Creater

Login by github, generate an redirect uri

GET /api/sessions/oauth/github

Request
Param Type Description
- - -
Response
Param Type Description
redirectURI String Redirect user to
Github OAuth Creater

Login by github, send code to server after user authentized

POST /api/sessions/oauth/github

Request
Param Type Description
code String -
state String -
Response
Param Type Description
accessToken String See Login
expiresIn Int See Login
tokenType String See Login
refreshToken String See Login
Remark
  • Github should take params code and state, simply forward to server
  • You should reject the access without code and state, such as redirect to welcome page

User

Todo

Todo List

Todo List Folder

Sharing

File

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func Run

func Run() (s *Server)

func (*Server) ErrorStream

func (s *Server) ErrorStream() <-chan error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL