passport-42

OAuth 2.0 홈  |  Apigee X  |  Google Cloud

42 API 쓰는 법

https://github.com/innovationacademy-kr/42oauth

https://github.com/pandark/passport-42-example

[NODE] 📚 Passport 모듈 사용법 (그림으로 처리 과정 💯 이해하기)

클라이언트 access_token

curl -X POST --data "grant_type=client_credentials&client_id=MY_AWESOME_UID&client_secret=MY_AWESOME_SECRET" <https://api.intra.42.fr/oauth/token>
{
"access_token":"42804d1f2480c240f94d8f24b45b318e4bf42e742f0c06a42c6f4242787af42d",
"token_type":"bearer",
"expires_in":7200,
"scope":"public",
"created_at":1443451918
}

사용자 42 로그인

Web application flow

1. 42 access를 요청하도록 사용자 리다이렉션

<https://api.intra.42.fr/oauth/authorize?client_id=your_very_long_client_id&redirect_uri=http%3A%2F%2Flocalhost%3A1919%2Fusers%2Fauth%2Fft%2Fcallback&response_type=code&scope=public&state=a_very_long_random_string_witchmust_be_unguessable>'
이름 유형 설명
client_id string 필수 . 등록할 때 42에서 받은 클라이언트 ID입니다 .
redirect_uri string 필수 . 승인 후 사용자가 전송되는 앱의 URL입니다. 리디렉션 URL 에 대한 자세한 내용은 아래를 참조하십시오 .
scope string 공백으로 구분된 범위 목록입니다 . 제공되지 않은 경우 scope앱에 대한 유효한 토큰이 없는 사용자에 대한 범위의 빈 목록이 기본적으로 사용됩니다. 앱에 대한 유효한 토큰이 이미 있는 사용자의 경우 범위 목록이 있는 OAuth 승인 페이지가 사용자에게 표시되지 않습니다. 대신 흐름의 이 단계는 사용자가 마지막으로 흐름을 완료했을 때 사용된 것과 동일한 범위로 자동으로 완료됩니다.
state string 추측할 수 없는 임의의 문자열입니다. 교차 사이트 요청 위조 공격으로부터 보호하는 데 사용됩니다.
response_type string 응답 유형입니다. 보통 code.