# 7회차

## passport

* nodejs 용 인증관련 모듈
* facebook, kakao 등등 사용

```javascript
npm install –save express-session
// 세션사용
npm install –save passport
// passport 다운로드
npm install –save passport-local
// local 방식으로 저장가능하게 사용
npm install –save connect-flash
// 로그인성공 or 실패시 flash message 사용
```

* passport 적용순서
* 정책작성&#x20;
  * 필드 및 passport 콜백 인증부분작성
* serializeUser, deserializeUser 작성
  * 첫 로그인시, 그 이후 조회 시 사용
* router (  POST , GET ) 적용

## Facebook Login

1. 페이스북 개발자 계정 생성
2. 인증 과정

   1\) 페이스북 로그인클릭

   2\) 페이스북 페이지 이동

   3\) 인증성공후 토큰 발행

   4\) 토큰으로 profile 정보 요청

   5\) profile 정보와 함께 내 사이트로 이동( call backurl )
3. 구현 과정

   1\) FacebookStrategy 작성

   2\) 인증링크 생성

   3\) callback받는 페이지 작성

   4\) 성공후 Redirect페이지 작성


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://incheol-jung.gitbook.io/docs/study/nodejs/2018-01-16-nodejs-7st.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
