You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ The documentation is dynamically generated by the server using [Swagger](https:/
11
11
12
12
- Set up your [environment](#environment)
13
13
- Install [docker-compose](https://docs.docker.com/compose/install/) and do `docker-compose up`
14
+
- for information on how to authenticate for the API, see [authentication](#authentication)
14
15
15
16
## Set up guide: The 'bothersome' way
16
17
@@ -30,6 +31,7 @@ Requirements:
30
31
Run the server:
31
32
-`pipenv run python src/runserver.py`
32
33
- Run with flag `--reset-db` to drop and recreate all tables on start
34
+
- for information on how to authenticate for the API, see [authentication](#authentication)
33
35
34
36
## Environment
35
37
@@ -45,7 +47,22 @@ Run the server:
45
47
46
48
Your `.env` file should now look something like [example.env](https://github.com/ProgrammingBuddies/programmingbuddies-api/blob/develop/example.env)
47
49
48
-
### Testing
50
+
## Authentication
51
+
#### Login
52
+
-`/login` route logs in if the user exists in the database, otherwise returns a error message and code in the URL
53
+
- to log in you have to specify several attributes
54
+
-`account` - currently `github` is the only value that is supported
55
+
-`username` - your username of account on specified platform in the previous step
56
+
-`redirect` - url where should you be redirected after authenticating with OAuth
57
+
- put it all these together `https://<url:port>/login?account=<account>&username=<username>&redirect=<redirect>`
58
+
- e.g.: `https://localhost:5001/login?account=github&username=freddy&redirect=https://localhost:5001` for GitHub account with name `freddy` while developing local with the server hosted on `localhost:5001`
59
+
- you will be redirected to the specified url and get data with it
60
+
- if the request failed - user was not registered before (user not found in the database), you will get an error message and code
61
+
- if the request succeeded - you will get a JWT `token` in the URL, that is what you need to authenticate
62
+
- add to your requests `Authorization` header with a value `Bearer <token>` where you replace `<token>` with your `token` acquired in the step above
63
+
#### Register
64
+
65
+
## Testing
49
66
50
67
- to run multiple tests just specify the directory which contains them for example `pipenv run pytest tests/`
51
68
- this will run all the tests in the `tests` directory
0 commit comments