No release in over 3 years
A Ruby gem providing OmniAuth OAuth2 strategy for Naver authentication. Supports modern OAuth2 practices with customizable scopes and proper error handling.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 5.0
~> 13.0
~> 1.21

Runtime

 Project Readme

OmniAuth Naver OAuth2

네이버 인증을 위한 현대적인 OmniAuth OAuth2 strategy를 제공하는 Ruby gem입니다. 기존 omniauth-naver와 달리 스코프 설정이 가능하고 최신 OAuth2 표준을 따릅니다.

설치

gem install omniauth-naver-oauth2

사용법

Rails 설정

# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  # 기본
  provider :naver, ENV['NAVER_CLIENT_ID'], ENV['NAVER_CLIENT_SECRET']
  
  # + Options
  provider :naver, ENV['NAVER_CLIENT_ID'], ENV['NAVER_CLIENT_SECRET'], {
    scope: 'profile,email',
    redirect_url: 'http://localhost:3000/auth/naver/callback'
  }

end

인증 해시

# request.env['omniauth.auth']
{
  provider: 'naver',
  uid: '48436401',
  info: {
    name: '홍길동',
    email: 'example@naver.com',
    nickname: '길동',
    image: 'https://phinf.pstatic.net/contactthumb/52/2014/8/4/example.jpg',
    gender: 'male', # 'male', 'female', or nil
    age: '30-39',
    birthday: '01-08',
    birthyear: '1990'
  },
  credentials: {
    token: 'ACCESS_TOKEN',
    expires_at: 1234567890,
    expires: true
  },
  extra: {
    raw_info: { ... },
    response: { ... }
  }
}

Contribute

버그 신고와 PR은 https://github.com/GoCoder7/omniauth-naver-oauth2 로 부탁드립니다.

License

MIT