Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +4 -4
app/main.py
CHANGED
|
@@ -117,7 +117,7 @@ def auth_google():
|
|
| 117 |
include_granted_scopes="true",
|
| 118 |
)
|
| 119 |
|
| 120 |
-
# 馃敟
|
| 121 |
oauth_flow_global[state] = flow
|
| 122 |
|
| 123 |
return RedirectResponse(url=authorization_url)
|
|
@@ -126,7 +126,6 @@ def auth_google():
|
|
| 126 |
return {
|
| 127 |
"ok": False,
|
| 128 |
"error": str(exc),
|
| 129 |
-
"message": "Nao foi possivel iniciar a autorizacao Google OAuth.",
|
| 130 |
}
|
| 131 |
|
| 132 |
|
|
@@ -141,11 +140,12 @@ def oauth2callback(code: str = Query(...), state: str = Query(...)):
|
|
| 141 |
status_code=400,
|
| 142 |
)
|
| 143 |
|
|
|
|
| 144 |
flow.fetch_token(code=code)
|
| 145 |
|
| 146 |
save_credentials(flow.credentials)
|
| 147 |
|
| 148 |
-
#
|
| 149 |
oauth_flow_global.pop(state, None)
|
| 150 |
|
| 151 |
return HTMLResponse(
|
|
@@ -165,7 +165,7 @@ def oauth2callback(code: str = Query(...), state: str = Query(...)):
|
|
| 165 |
status_code=500,
|
| 166 |
)
|
| 167 |
|
| 168 |
-
|
| 169 |
@app.get("/auth/status")
|
| 170 |
def auth_status():
|
| 171 |
credentials = load_credentials()
|
|
|
|
| 117 |
include_granted_scopes="true",
|
| 118 |
)
|
| 119 |
|
| 120 |
+
# 馃敟 ESSENCIAL
|
| 121 |
oauth_flow_global[state] = flow
|
| 122 |
|
| 123 |
return RedirectResponse(url=authorization_url)
|
|
|
|
| 126 |
return {
|
| 127 |
"ok": False,
|
| 128 |
"error": str(exc),
|
|
|
|
| 129 |
}
|
| 130 |
|
| 131 |
|
|
|
|
| 140 |
status_code=400,
|
| 141 |
)
|
| 142 |
|
| 143 |
+
# 馃敟 usa o MESMO flow (n茫o recria!)
|
| 144 |
flow.fetch_token(code=code)
|
| 145 |
|
| 146 |
save_credentials(flow.credentials)
|
| 147 |
|
| 148 |
+
# limpa mem贸ria
|
| 149 |
oauth_flow_global.pop(state, None)
|
| 150 |
|
| 151 |
return HTMLResponse(
|
|
|
|
| 165 |
status_code=500,
|
| 166 |
)
|
| 167 |
|
| 168 |
+
|
| 169 |
@app.get("/auth/status")
|
| 170 |
def auth_status():
|
| 171 |
credentials = load_credentials()
|