Skip to content

Commit b03ac22

Browse files
committed
OAuth guide - Login
1 parent c6c2343 commit b03ac22

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The documentation is dynamically generated by the server using [Swagger](https:/
1111

1212
- Set up your [environment](#environment)
1313
- 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)
1415

1516
## Set up guide: The 'bothersome' way
1617

@@ -30,6 +31,7 @@ Requirements:
3031
Run the server:
3132
- `pipenv run python src/runserver.py`
3233
- 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)
3335

3436
## Environment
3537

@@ -45,7 +47,22 @@ Run the server:
4547

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

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
4966

5067
- to run multiple tests just specify the directory which contains them for example `pipenv run pytest tests/`
5168
- this will run all the tests in the `tests` directory

0 commit comments

Comments
 (0)