Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Integrating LINE Login with Firebase

972 vues

Publié le

Integrating LINE Login with Firebase
โดยคุณตี๋ จิรวัฒน์ กรัณย์วิทยาการ, Google Developer Expert Firebase
https://www.facebook.com/events/351387272028975/

Publié dans : Technologie
  • Soyez le premier à commenter

Integrating LINE Login with Firebase

  1. 1. Integrating LINE Login with Firebase @Jirawatee
  2. 2. closing the distance
  3. 3. Why LINE Login ? smartphone usersusers 95%42M
  4. 4. Platforms
  5. 5. LINE Login APIs v2.x Authorization Request Getting access token Getting user profiles Verifying access tokens Refreshing access tokens Logging out users
  6. 6. Scopes User's profile information Profile ID token (JWT) OpenID User's profile including email. (openid scope must be specified) Email
  7. 7. User's email permission ● Released since Feb 28, 2018 ● Apply for the permission in the console by uploading a screenshot that explains why you need to obtain their email and what you will use it for
  8. 8. OpenID Connect iss URL where the ID token is generated. sub {user_id} aud {client_id} name Display Name picture User’s profile image URL email example@domain.com phone_number coming soon...
  9. 9. LINE Login v1 to be discontinued On March 31, 2018 ● access token: https://api.line.me/v1/oauth/verify On April 30, 2018 ● Get user profile: https://api.line.me/v1/profile ● Logout: https://api.line.me/v1/oauth/logout On June 30, 2018 ● Verify access token: https://api.line.me/v1/oauth/verify ● LINE SDK: iOS and Android version 3.x or earlier After an endpoint is terminated, any access to it will result in a 4XX status code as a response.
  10. 10. ● Converting an MID to a User ID https://developers.line.me/en/docs/ line-login/converting-mid-to-userid/ MID(v1.0) != User ID(v2.x)
  11. 11. “Trust Me I’m an Engineer”
  12. 12. End Goal Today
  13. 13. 2. Get Access Tokens 6. Log in with Custom Token 4. Get / Set Firebase User 3. Verify Access Token 1. Request Authorization Code 5. Create Firebase Custom TokenStep by Step
  14. 14. 0. Create a Channel https://developers.line.me
  15. 15. 1.Request Authorization Code https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=<YOUR_CLIENT_ID>&redirect_uri=<YOUR_CALLBAC K_URL>&state=12345abcde&scope=openid%20profile
  16. 16. 2. Get an access token
  17. 17. ID Token
  18. 18. exports.makeUpper case = functions.database( )... exports.moderate = functions.database( )... exports.sendEmail = functions.database( )... Events Hosted & Scalable Based on GCP
  19. 19. Firebase Admin SDK
  20. 20. Prepare data and call API
  21. 21. function verifyLineToken(body) { return request({ method: 'GET', uri: `https://api.line.me/oauth2/v2.1/verify?access_token=${body.access_token}`, json: true }).then((response) => { if (response.client_id !== functions.config().line.channelid) { return Promise.reject(new Error('LINE channel ID mismatched')); } return getFirebaseUser(body); }); } 3. Verify Access Token
  22. 22. function getFirebaseUser(body) { const firebaseUid = `line:${body.id}`; return admin.auth().getUser(firebaseUid).then(function(userRecord) { return userRecord; }).catch((error) => { if (error.code === 'auth/user-not-found') { return admin.auth().createUser({ uid: firebaseUid, displayName: body.name, photoURL: body.picture, email: body.email }); } return Promise.reject(error); }); } 4. Get / Set Firebase User
  23. 23. then((userRecord) => { return admin.auth().createCustomToken(userRecord.uid); }).then((token) => { return token; }); 5. Create Firebase Custom Token
  24. 24. FirebaseAuth auth = FirebaseAuth.getInstance(); auth.signInWithCustomToken(firebaseToken).addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { DialogHelper.dismissDialog(); if (task.isSuccessful()) { // Login completed with Firebase } else { // Login Failed } } }); 6. Login with Custom Token
  25. 25. User Journey
  26. 26. Login session
  27. 27. Demo
  28. 28. Blog & Source Code https://goo.gl/1kq9t9 https://goo.gl/soxeRi Slide - https://goo.gl/m3rAdS
  29. 29. “A technology without a community has no meaningful”
  30. 30. fb.com/groups/LINEDEVTH medium.com/LINE-Developer-Thailand fb.com/FirebaseThailand Follow us
  31. 31. Thank you @Jirawatee #LINEThailand #LINEDevMeetup

×