Websocket
- Continuing 42login but problem with api https://api.intra.42.fr/v2/me
This commit is contained in:
14
site/game/node_modules/.vite/deps/_metadata.json
generated
vendored
14
site/game/node_modules/.vite/deps/_metadata.json
generated
vendored
@ -1,31 +1,31 @@
|
|||||||
{
|
{
|
||||||
"hash": "84705c79",
|
"hash": "cfc1d7ec",
|
||||||
"configHash": "e6b0507d",
|
"configHash": "53d5649f",
|
||||||
"lockfileHash": "c0b533f0",
|
"lockfileHash": "c0b533f0",
|
||||||
"browserHash": "e8cce6d5",
|
"browserHash": "a1ea8e7b",
|
||||||
"optimized": {
|
"optimized": {
|
||||||
"stats.js": {
|
"stats.js": {
|
||||||
"src": "../../stats.js/build/stats.min.js",
|
"src": "../../stats.js/build/stats.min.js",
|
||||||
"file": "stats__js.js",
|
"file": "stats__js.js",
|
||||||
"fileHash": "76e64697",
|
"fileHash": "8aa61490",
|
||||||
"needsInterop": true
|
"needsInterop": true
|
||||||
},
|
},
|
||||||
"three": {
|
"three": {
|
||||||
"src": "../../three/build/three.module.js",
|
"src": "../../three/build/three.module.js",
|
||||||
"file": "three.js",
|
"file": "three.js",
|
||||||
"fileHash": "2c53ee09",
|
"fileHash": "01396a1e",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
},
|
},
|
||||||
"three/examples/jsm/controls/OrbitControls.js": {
|
"three/examples/jsm/controls/OrbitControls.js": {
|
||||||
"src": "../../three/examples/jsm/controls/OrbitControls.js",
|
"src": "../../three/examples/jsm/controls/OrbitControls.js",
|
||||||
"file": "three_examples_jsm_controls_OrbitControls__js.js",
|
"file": "three_examples_jsm_controls_OrbitControls__js.js",
|
||||||
"fileHash": "ed778cce",
|
"fileHash": "5846be4b",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
},
|
},
|
||||||
"three/examples/jsm/lights/RectAreaLightUniformsLib.js": {
|
"three/examples/jsm/lights/RectAreaLightUniformsLib.js": {
|
||||||
"src": "../../three/examples/jsm/lights/RectAreaLightUniformsLib.js",
|
"src": "../../three/examples/jsm/lights/RectAreaLightUniformsLib.js",
|
||||||
"file": "three_examples_jsm_lights_RectAreaLightUniformsLib__js.js",
|
"file": "three_examples_jsm_lights_RectAreaLightUniformsLib__js.js",
|
||||||
"fileHash": "ca8c3839",
|
"fileHash": "165faab8",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* connectedWith42.js :+: :+: :+: */
|
/* connectedWith42.js :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: edbernar <edbernar@student.42.fr> +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/09 09:15:24 by edbernar #+# #+# */
|
/* Created: 2024/08/09 09:15:24 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/09 09:18:26 by edbernar ### ########.fr */
|
/* Updated: 2024/08/09 23:23:46 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,9 +16,9 @@ function connectedWith42Func()
|
|||||||
{
|
{
|
||||||
const token42 = window.location.search.split('code=')[1];
|
const token42 = window.location.search.split('code=')[1];
|
||||||
|
|
||||||
console.log("connectedWith42Func");
|
if (!token42)
|
||||||
|
return ;
|
||||||
sendRequest("login", {type: "by42", token: token42});
|
sendRequest("login", {type: "by42", token: token42});
|
||||||
console.log(token42);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { connectedWith42Func };
|
export { connectedWith42Func };
|
@ -3,10 +3,10 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# login42.py :+: :+: :+: #
|
# login42.py :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: edbernar <edbernar@student.42.fr> +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/08/09 09:32:17 by edbernar #+# #+# #
|
# Created: 2024/08/09 09:32:17 by edbernar #+# #+# #
|
||||||
# Updated: 2024/08/09 10:03:54 by edbernar ### ########.fr #
|
# Updated: 2024/08/10 00:42:38 by edbernar ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -17,34 +17,36 @@ import os
|
|||||||
UID42 = os.environ.get("uid")
|
UID42 = os.environ.get("uid")
|
||||||
SECRET42 = os.environ.get("secret")
|
SECRET42 = os.environ.get("secret")
|
||||||
TOKENURL = 'https://api.intra.42.fr/oauth/token'
|
TOKENURL = 'https://api.intra.42.fr/oauth/token'
|
||||||
|
|
||||||
INFOURL = 'https://api.intra.42.fr/v2/me'
|
INFOURL = 'https://api.intra.42.fr/v2/me'
|
||||||
|
|
||||||
access_token = ""
|
access_token = ""
|
||||||
|
|
||||||
|
if (UID42 == None or SECRET42 == None):
|
||||||
|
print("Please set the environment variables uid and secret")
|
||||||
|
exit()
|
||||||
|
|
||||||
def main42login(content):
|
def main42login(content):
|
||||||
global access_token
|
global access_token
|
||||||
|
|
||||||
print(UID42)
|
|
||||||
print(SECRET42)
|
|
||||||
data = {
|
|
||||||
'grant_type': 'client_credentials',
|
|
||||||
'client_id': UID42,
|
|
||||||
'client_secret': SECRET42,
|
|
||||||
}
|
|
||||||
response = requests.post(TOKENURL, data=data)
|
|
||||||
access_token = response.json()["access_token"]
|
|
||||||
data = {
|
|
||||||
'grant_type': 'authorization_code',
|
|
||||||
'client_id': UID42,
|
|
||||||
'client_secret': SECRET42,
|
|
||||||
'code': content["token"],
|
|
||||||
'redirect_uri': 'http://localhost:3000',
|
|
||||||
}
|
|
||||||
response = requests.get('https://api.intra.42.fr/v2/me', headers={'Authorization': 'Bearer ' + access_token})
|
|
||||||
|
|
||||||
if (response.status_code != 200):
|
try:
|
||||||
raise Exception("")
|
data = {
|
||||||
|
'grant_type': 'client_credentials',
|
||||||
response = response.json()
|
'client_id': UID42,
|
||||||
print(response)
|
'client_secret': SECRET42,
|
||||||
|
}
|
||||||
|
response = requests.post(TOKENURL, data=data)
|
||||||
|
access_token = response.json()["access_token"]
|
||||||
|
print("Access Token: ", access_token)
|
||||||
|
headers = {
|
||||||
|
'Authorization': 'Bearer ' + access_token,
|
||||||
|
}
|
||||||
|
response = requests.get(INFOURL, headers=headers)
|
||||||
|
print("Code: ", response.status_code)
|
||||||
|
response = response.json()
|
||||||
|
print(response)
|
||||||
|
except Exception as e:
|
||||||
|
print("Error in main42login")
|
||||||
|
print(e)
|
||||||
|
|
Reference in New Issue
Block a user