Skip to content

Instantly share code, notes, and snippets.

@jagdeepsingh
Last active June 20, 2017 12:43
Show Gist options
  • Save jagdeepsingh/44a6ba001c31b3468a8cce3e30e8d8ac to your computer and use it in GitHub Desktop.
Save jagdeepsingh/44a6ba001c31b3468a8cce3e30e8d8ac to your computer and use it in GitHub Desktop.
LINE

LINE

Setup

  1. Download the LINE mobile app and register using your mobile number.

  2. Under Settings -> Account:

    • Complete Email Registration by setting an email id and password.
    • Enable Allow Login.
  3. Now visit Business Center. Click on Start using LINE Login.

  4. Under Create an Account, enter email to be used for Business Center. An email will be sent with the registration URL. Click on that URL to verify your email.

  5. Enter more details of your business:

    • Profile Information:
      • Enter Mobile Number
    • Enterprise Information:
      • Select Enterprise Type as Corporation
      • Enter other details
    • Click Continue.
  6. On next page, under Accounts -> Your Accounts, click on Start Using Service -> Line Login.

  7. Next, click on Start using LINE Login.

  8. Set Business Account Name.

  9. Under Channel Information:

    • Enter Channel Description
    • Select Application Type as Web
    • Enter Email Address
    • Click OK.
  10. On next page, click Apply. Note down the CHANNEL_ID.

  11. Now, click on Line Developers.

  12. Agree to terms and conditions of use. It will take you to the application page.

  13. Under Basic Information, note down CHANNEL_SECRET.

  14. Under Technical Configuration, set Callback URL e.g. https://26ee637c.ngrok.io/path/to/line/callback

You are ready to use this application as a Login option for your users.

Add following to Gemfile:

gem 'omniauth-line', '~> 0.0.2'

Run bundle install.

# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :line, CHANNEL_ID, CHANNEL_SECRET, { callback_path: 'path/to/line/callback' }
end
!/ app/views/path/to/login.html.slim
= link_to 'Login via LINE', '/auth/line'
# app/controllers/sessions_controller.rb
def line_callback
  omniauth = request.env['omniauth.auth']      # => #<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=1500550135 refresh_token="QaH480MmHNhZBNHipabN" token=TOKEN> extra=#<OmniAuth::AuthHash> info=#<OmniAuth::AuthHash::InfoHash description=nil image=IMAGE_URL name="jdbhoewal"> provider="line" uid=UID>
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment