-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Linked ticket in Jira - https://hanagotchi.atlassian.net/browse/HAN-38 ## Describe your changes, marking the new features and possible risks - Se agrega un endpoint para login con google - Desde el front se envia un codigo de autenticacion que va a ser utilizado desde el back para obtener informacion del usuario y crearlo en la db de ser necesario. - Se le pega a "https://oauth2.googleapis.com/token" con el codigo que paso el front para obtener un token - Se le pega a "https://www.googleapis.com/oauth2/v2/userinfo" con el token para obtener la informacion del usuario. Pueden ser los parametros: email, name, picture, y otros (https://any-api.com/googleapis_com/oauth2/docs/userinfo/oauth2_userinfo_get) pero depende de la cuenta del usuario. ## Pruebas Para probar en endpoint hay que generar el token que nos pasaria el front. Es un token **single use**. Los pasos son: - Acceder a esta url https://accounts.google.com/o/oauth2/auth?client_id=242595357606-8j31hrog4d785563t3f03qc01hpevr84.apps.googleusercontent.com&redirect_uri=http://localhost:8000/auth/google/callback&scope=openid%20email&response_type=code&access_type=offline - Loguearse con la cuenta fiuba. Solo nuestras cuentas fiuba estan autorizadas. - Agarrar el query param _code_ de la url a la que te redirecciona - Desencodearlo (https://www.url-encode-decode.com/) - Ponerlo en el body de la request
- Loading branch information
Showing
10 changed files
with
119 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
CREATE SCHEMA IF NOT EXISTS dev; | ||
|
||
CREATE TABLE IF NOT EXISTS dev.users ( | ||
id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(255), | ||
email VARCHAR(255) UNIQUE NOT NULL, | ||
gender VARCHAR(20), | ||
photo VARCHAR(255) | ||
); | ||
|
||
INSERT INTO | ||
dev.users (name) | ||
VALUES ('Agus'), | ||
('Pach'), | ||
('Sofi'), | ||
('Violeta'); | ||
dev.users (name, email) | ||
VALUES ('Agus', 'agus@fi.uba.ar'), | ||
('Pach', 'pach@fi.uba.ar'), | ||
('Sofi', 'sofi@fi.uba.ar'), | ||
('Violeta', 'violeta@fi.uba.ar'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fastapi import HTTPException, status | ||
from typing import Optional | ||
|
||
|
||
class AuthenticationError(HTTPException): | ||
def __init__(self, message: Optional[str] = "Could not authenticate"): | ||
status_code = status.HTTP_401_UNAUTHORIZED | ||
super().__init__(status_code=status_code, detail=message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ uvicorn | |
python-dotenv | ||
flake8 | ||
psycopg2-binary | ||
SQLAlchemy | ||
SQLAlchemy | ||
requests_oauthlib |