Skip to content

Commit 050f9ae

Browse files
committed
Added instructions for registering
1 parent b03ac22 commit 050f9ae

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Requirements:
3131
Run the server:
3232
- `pipenv run python src/runserver.py`
3333
- 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)
34+
- For information on how to authenticate for the API, see [authentication](#authentication)
3535

3636
## Environment
3737

@@ -43,30 +43,36 @@ Run the server:
4343
- Create a new one and set the homepage url to `https://localhost:5001/` and Authorization callback to `https://localhost:5001/login/github/authorized`
4444
- Copy the Client Id and Client Secret from that site and save them in `.env` as `GITHUB_ID` and `GITHUB_SECRET` respectively
4545
4. Furthermore a `JWT_SECRET_KEY` is required for signing the JWT-tokens
46-
- pick a strong passphrase so that attackers can't brute-force it and sign tokens distinguishing as your server
46+
- Pick a strong passphrase so that attackers can't brute-force it and sign tokens distinguishing as your server
4747

4848
Your `.env` file should now look something like [example.env](https://github.com/ProgrammingBuddies/programmingbuddies-api/blob/develop/example.env)
4949

5050
## Authentication
51+
- To authenticate you have to specify several attributes
52+
- `account` - currently `github` is the only supported value
53+
- `username` - your username of account on specified platform in the previous point
54+
- `redirect` - url where should you be redirected after authenticating with OAuth
55+
- Put it all these together `https://<url:port>/<login-or-register>?account=<account>&username=<username>&redirect=<redirect>`
56+
- e.g.: `https://localhost:5001/<login-or-register>?account=github&username=freddy&redirect=https://localhost:5001` will `login-or-register` using GitHub account with name `freddy` while developing local with the server hosted on `localhost:5001`
57+
- You will be redirected to the specified url and get data with it
58+
- If the request **failed** - when logging in and user was not registered (user not found in the database) or there was any internal error, you will get an error message and code
59+
- If the request **succeeded** - you will get a JWT `token` in the URL, that is what you need to authenticate
60+
- Add to your requests `Authorization` header with a value `Bearer <token>` where you replace `<token>` with your `token` acquired in the step above
5161
#### Login
5262
- `/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+
- Usage: `https://<url:port>/login?account=<account>&username=<username>&redirect=<redirect>`
64+
- e.g.: `https://localhost:5001/login?account=github&username=freddy&redirect=https://localhost:5001`
65+
6366
#### Register
67+
- `/register` route either logs in if the user exists in the database or registers (creates) a new user, in case of failure returns a error message and code in the URL
68+
- Usage: `https://<url:port>/register?account=<account>&username=<username>&redirect=<redirect>`
69+
- e.g.: `https://localhost:5001/register?account=github&username=freddy&redirect=https://localhost:5001`
6470

6571
## Testing
6672

67-
- to run multiple tests just specify the directory which contains them for example `pipenv run pytest tests/`
68-
- this will run all the tests in the `tests` directory
69-
- if you want to run test cases only in a particular file, then just give the full file path `pipenv run pytest tests/example.py`
73+
- To run multiple tests just specify the directory which contains them for example `pipenv run pytest tests/`
74+
- This will run all the tests in the `tests` directory
75+
- If you want to run test cases only in a particular file, then just give the full file path `pipenv run pytest tests/example.py`
7076

7177
## Tech stack:
7278

0 commit comments

Comments
 (0)