MEAN 스택을 사용하는 REST API를 사용하고 Passport JS 인증을 관리하는 응용 프로그램에서 작업하고 있습니다.로그인 한 사용자에 대해 Google에 연결 (권한 부여)하는 Google
인증에서 우리는 백엔드와 프론트 엔드 간의 통신을 위해 JTW 토큰을 사용합니다. 토큰은 로컬 사용자 이름과 암호를 기반으로 생성됩니다.
이제 google 캘린더 API에 사용할 프로필에 사용자의 Google 계정을 '추가'(승인)하고 싶습니다. (this->https://github.com/wanasit/google-calendar을 사용)
이미 Google 인증 페이지로 사용자를 보내고 토큰을 다시 가져 왔습니다. 문제는 사용자가 페이지로 리다이렉트되면 사용자 요청을 확인하는 JWT 토큰을 잃어 버리는 것이다.
현재 로그인 한 사용자를 얻거나 authorize 메서드를 호출 할 때 일부 사용자 지정 콜백 권한 헤더/매개 변수를 전달하는 다른 방법이 있습니까?
auth.js :
var googleParams = {
clientID: config.auth.google.clientID,
clientSecret: config.auth.google.clientSecret,
callbackURL: config.auth.google.callbackURL
}
var googleStrategy = new GoogleStrategy(googleParams, function (token, refreshToken, profile, done) {
profile.token = token;
return done(null, profile);
});
경로 :이
rotas.get(
'/google',
auth.authenticate(), // will check the current user
auth.isLoggedIn, // make sure the user is really logged in
auth.authorize('google', { scope: googleScope, passReqToCallback: true }) // redirects to google to get the token
);
rotas.get('/callback/google',
auth.authorize('google', { scope: googleScope, passReqToCallback: true })
auth.authRedirect()
);
auth.authRedirect()
기능은 위의 내가 찾은 가장 가까운 솔루션입니다. 그것은 사용자가 인증 된 프론트 엔드의 알려진 경로로 사용자를 리디렉션하는 Express 미들웨어입니다.하지만 필요한 모든 Google 프로필과 정보를 가져올 수는 없습니다 ...
흠 ... 좋은! 나는이'국가'재산을 몰랐다. 잘 했어. –