Skip to content

Instantly share code, notes, and snippets.

@jagdeepsingh
Last active June 16, 2017 09:58
Show Gist options
  • Save jagdeepsingh/fde63a8fab90cdda4428ef05eb47701c to your computer and use it in GitHub Desktop.
Save jagdeepsingh/fde63a8fab90cdda4428ef05eb47701c to your computer and use it in GitHub Desktop.
Naver

Naver

Login or Sign up for an account on Naver.

Visit here to register an application to use Naver API.

Note down the CLIENT_ID and CLIENT_SECRET under Summary on application dashboard.

Add following to Gemfile:

gem 'omniauth-naver', '~> 0.1.0'

Run bundle install.

# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :naver, CLIENT_ID, CLIENT_SECRET,
           { callback_path: '/path/to/callback/action' }
end
!/ app/views/sessions/login.html.slim
= link_to 'Login via Naver', '/auth/naver'
# app/controllers/sessions_controller.rb
def naver_callback
  omniauth = request.env['omniauth.auth']        # => #<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=1497596041 refresh_token="jC40Md" token="AAAAQU"> extra=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash data=#<OmniAuth::AuthHash response=#<OmniAuth::AuthHash age="20-29" birthday="01-20" email="[email protected]" enc_id="200184" gender="M" id="144207" name="Jagdeep Singh" nickname="Jagdeep Singh" profile_image="https://ssl.pstatic.net/path/to/image.png"> result=#<OmniAuth::AuthHash message="success" resultcode="00">>>> info=#<OmniAuth::AuthHash::InfoHash email="[email protected]" gender="male" image="https://ssl.pstatic.net/path/to/image.png" name="Jagdeep Singh"> provider="naver" uid="200184">
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment