Use LINE Login with Firebase
This sample shows how to Sign in Firebase using LINE Login. In this sample we use LINE iOS and Android SDK to get LINE user information then create a Firebase Custom Token (using the Line user ID).
Setup the sample
LINE business account's creation and setup
- Follow the instruction in LINE Developers document to setup a LINE business account.
- After finished setting up your channel, follow the document to integrate LINE SDK in your iOS and Android app. It should include:
- Open Technical Configuration page of your LINE channel, and update the following values:
- iOS Bundle ID:
- Android Package Name:
- Android Package Signature: The SHA1 value of your keystore, without semicolons
- iOS Bundle ID:
- Download the LINE SDK for iOS and Android from LINE developers site and add them to your apps. The latest version of LINE SDK may have different API with that used to create the sample app, so you may need to make some changes to the sample apps. LINE SDK versions being used in building the sample apps are:
- iOS: 3.2.1
- Android: 3.1.21
- Update your Channel ID to your apps
- iOS: Update
- Android: Update
- iOS: Update
Firebase app creation and setup
- Create a Firebase project using the Firebase Developer Console.
- For the iOS app: Go to Firebase Console > Overview > Add Firebase to your iOS app and create an app with the Bundle ID of
com.google.firebase.LINELoginDemo. This will trigger your browser to download a
GoogleService-Info.plistconfig file. Add this config file to your sample iOS app, then run
pod installto make download necessary CocoaPods dependencies.
- For the Android app: Go to Firebase Console > Overview > Add Firebase to your Android app and create an app with the Package name of
com.google.firebase.linelogindemo. This will trigger your browser to download a
google-services.jsonconfig file. Add this config file to your sample Android app.
- If you have problem creating a your Android app, try changing the Android app's package name to your own value (e.g.
com.yourdomain.linelogindemo) and try again. Remember to update the package name inside your Android app and in your LINE Channel's Technical Configuration page as well.
Create and provide a Service Account's keys:
- Create a Service Accounts file as described in the Server SDK setup instructions.
- Save the Service Account credential file as
service-account.jsonand copy it to
functions/. (You should not check in this file to your repository as it contains secret key to grant full admin access to your Firebase account.)
Run the sample
Before running your iOS and Android sample app, you need to deploy your function to Firebase.
- Enable Billing on your Firebase the project by switching to the Blaze plan, this is currently needed to be able to perform HTTP requests to external services from a Cloud Function.
firebase use --addand choose your Firebase project. This will configure the Firebase CLI to use the correct project locally.
- Copy the Channel ID of your LINE Business account and use them to set the
line.channelidin Google Cloud environment variables. For this use:
firebase functions:config:set line.channelid="<your_channel_id>"
firebase deploy ---only functionsto deploy the sample. The first time the Functions are deployed the process can take several minutes.
Then update your iOS and Android app with the domain name of your Cloud Functions. You can find it in the log of Firebase CLI after sucessfully deploying the function. It should look like
https://us-central1-<your Firebase project id>.cloudfunctions.net
- iOS: In
Constant.h, replace the placeholder text with your domain.
- Android: In
configs.xml, replace the placeholder text with your domain.
Build the sample iOS and Android app and run them on your devices. Those sample apps should be working by now. If you see any compile errors or the apps crash when starting, please refer back to the setup instruction above and check if you missed anything.