diff --git a/docs/_sources/api/auth.rst.txt b/docs/_sources/api/auth.rst.txt index 265416ca..c5c7dc6e 100644 --- a/docs/_sources/api/auth.rst.txt +++ b/docs/_sources/api/auth.rst.txt @@ -1,8 +1,6 @@ Authentication ############## -work in progress - .. autoflask:: fittrackee_api:create_app() :endpoints: auth.register_user, diff --git a/docs/api/activities.html b/docs/api/activities.html index 7d6f44dd..1189b658 100644 --- a/docs/api/activities.html +++ b/docs/api/activities.html @@ -461,7 +461,7 @@
file – gpx file
file – gpx file (allowed extensions: .gpx, .zip)
data – sport id and notes (example: {"sport_id": 1, "notes": ""}
)
201 Created – activity created
400 Bad Request – invalid payload
Invalid payload.
No file part.
No selected file.
File extension not allowed.
401 Unauthorized – invalid token
204 No Content – activity deleted
401 Unauthorized – invalid token
404 Not Found – activity not found
500 Internal Server Error – Error. Please try again or contact the administrator.
work in progress
POST
/api/auth/register
¶register a user
+Example request:
+POST /auth/register HTTP/1.1
+Content-Type: application/json
+
Example responses:
+successful registration
HTTP/1.1 201 CREATED
+Content-Type: application/json
+
+{
+ "auth_token": "JSON Web Token",
+ "message": "Successfully registered.",
+ "status": "success"
+}
+
error on registration
HTTP/1.1 400 BAD REQUEST
+Content-Type: application/json
+
+{
+ "message": "Errors: Valid email must be provided.\n",
+ "status": "error"
+}
+
username (string) – user name (3 to 12 characters required)
email (string) – user email
password (string) – password (8 characters required)
password_conf (string) – password confirmation
201 Created – Successfully registered.
Invalid payload.
Sorry. That user already exists.
Username: 3 to 12 characters required.
Valid email must be provided.
Password and password confirmation don’t match.
Password: 8 characters required.
500 Internal Server Error – Error. Please try again or contact the administrator.
POST
/api/auth/login
¶user login
+Example request:
+POST /auth/login HTTP/1.1
+Content-Type: application/json
+
Example responses:
+successful login
HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "auth_token": "JSON Web Token",
+ "message": "Successfully logged in.",
+ "status": "success"
+}
+
error on login
HTTP/1.1 404 NOT FOUND
+Content-Type: application/json
+
+{
+ "message": "Invalid credentials.",
+ "status": "error"
+}
+
email (string) – user email
password_conf (string) – password confirmation
200 OK – Successfully logged in.
404 Not Found – Invalid credentials.
500 Internal Server Error – Error. Please try again or contact the administrator.
GET
/api/auth/logout
¶user logout
+Example request:
+GET /auth/logout HTTP/1.1
+Content-Type: application/json
+
Example responses:
+successful logout
HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "message": "Successfully logged out.",
+ "status": "success"
+}
+
error on login
HTTP/1.1 401 UNAUTHORIZED
+Content-Type: application/json
+
+{
+ "message": "Provide a valid auth token.",
+ "status": "error"
+}
+
Authorization – OAuth 2.0 Bearer Token
200 OK – Successfully logged out.
401 Unauthorized – Provide a valid auth token.
GET
/api/auth/profile
¶get authenticated user info
+Example request:
+GET /auth/profile HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "admin": false,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sun, 14 Jul 2019 14:09:58 GMT",
+ "email": "admin@example.com",
+ "first_name": null,
+ "id": 2,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 6,
+ "nb_sports": 3,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 67.895,
+ "total_duration": "6:50:27",
+ "username": "sam"
+ },
+ "status": "success"
+}
+
Authorization – OAuth 2.0 Bearer Token
200 OK – success.
401 Unauthorized – Provide a valid auth token.
POST
/api/auth/profile/edit
¶edit authenticated user
+Example request:
+POST /auth/profile/edit HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "admin": false,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sun, 14 Jul 2019 14:09:58 GMT",
+ "email": "admin@example.com",
+ "first_name": null,
+ "id": 2,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 6,
+ "nb_sports": 3,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 67.895,
+ "total_duration": "6:50:27",
+ "username": "sam"
+ },
+ "status": "success"
+}
+
first_name (string) – user first name
last_name (string) – user last name
location (string) – user location
bio (string) – user biography
birth_date (string) – user birth date (format: %Y-%m-%d
)
password (string) – user password
password_conf (string) – user password confirmation
timezone (string) – user time zone
Authorization – OAuth 2.0 Bearer Token
200 OK – User profile updated.
Invalid payload.
Password and password confirmation don’t match.
401 Unauthorized – Provide a valid auth token.
500 Internal Server Error – Error. Please try again or contact the administrator.
POST
/api/auth/picture
¶update authenticated user picture
+Example request:
+POST /auth/picture HTTP/1.1
+Content-Type: multipart/form-data
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "admin": false,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sun, 14 Jul 2019 14:09:58 GMT",
+ "email": "admin@example.com",
+ "first_name": null,
+ "id": 2,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 6,
+ "nb_sports": 3,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 67.895,
+ "total_duration": "6:50:27",
+ "username": "sam"
+ },
+ "status": "success"
+}
+
file – image file (allowed extensions: .jpg, .png, .gif)
Authorization – OAuth 2.0 Bearer Token
200 OK – User picture updated.
Invalid payload.
No file part.
No selected file.
File extension not allowed.
401 Unauthorized – Provide a valid auth token.
500 Internal Server Error – Error during picture update.
DELETE
/api/auth/picture
¶delete authenticated user picture
+Example request:
+DELETE /auth/picture HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 204 NO CONTENT
+Content-Type: application/json
+
Authorization – OAuth 2.0 Bearer Token
204 No Content – picture deleted
401 Unauthorized – Provide a valid auth token.
500 Internal Server Error – Error during picture deletion.