Line SDK wrapper for Expo 🚀
npm install expo-line-authentication
Line SDK wrapper for Expo (Ios, Android) 🚀
This library includes:
- LINE SDK v5 for iOS Swift, wrapped with Swift.
- LINE SDK v5 for Android, wrapped with Kotlin.
First, install the npm package with npx.
``bash`
npx expo install expo-line-authentication
1. Follow instructions in Integrating LINE Login with your iOS app.
1. In your manifest add xmlns:tools="http://schemas.android.com/tools" in your manifest tag and also tools:replace="android:allowBackup" in your application tag
First, require the ExpoLineModule module:
`javascript
import * as Line from 'expo-line-authentication';
Line.setup({channelID: 'YOUR-CHANNEL-ID'});
`
Then, you can start using all the functions that are available:
| Function | Description |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| login(args?: LoginArguments): Promise | Starts the login flow of Line's SDK (Opens the apps if it's installed and defaults to the browser otherwise). It accepts the same argumements as the LineSDK, in an object { key: value }, defaults the same way as LineSDK too. |getCurrentAccessToken(): Promise
| | Returns the current access token for the currently logged in user. |getProfile(): Promise
| | Returns the profile of the currently logged in user. |logout(): Promise
| | Logs out the currently logged in user. |refreshToken(): Promise
| | Refreshes the access token and returns it. |verifyAccessToken(): Promise
| | Verifies the access token and returns it. |getBotFriendshipStatus(): Promise
| | Gets bot friendship status if configured. |
The following objects are returned on the methods described above:
1. UserProfile:
`typescript
{
/// The user ID of the current authorized user.
userID: String
/// The display name of the current authorized user.
displayName: string
/// The profile image URL of the current authorized user. null if the user has not set a profile
/// image.
pictureURL?: string
/// The status message of the current authorized user. null if the user has not set a status message.`
statusMessage?: string
}
2. AccessToken:
`typescriptcreatedAt
{
/// The value of the access token.
access_token: String
/// The expiration time of the access token. It is calculated using and the validity periodcreatedAt
/// of the access token. This value might not be the actual expiration time because this value depends
/// on the system time of the device when is determined..openID
expires_in: String
/// The raw string value of the ID token bound to the access token. The value exists only if the access token
/// is obtained with the permission.`
id_token?: String
}
3. AccessTokenVerifyResult:
`typescript
{
// The channel ID bound to the access token.
client_id: String
/// The amount of time until the access token expires.
expires_in: String
/// Valid permissions of the access token separated by spaces
scope: String
}
`
4. LoginResult
`typescriptaccessToken
{
/// The access token obtained by the login process.
accessToken: AccessToken
/// The permissions bound to the object by the authorization process. Scope has them separated by spaces.profile
scope: String
/// Contains the user profile including the user ID, display name, and so on. The value exists only when the
/// permission is set in the authorization request.null
userProfile?: UserProfile
/// Indicates that the friendship status between the user and the bot changed during the login. This value is
/// non- only if the .botPromptNormal or .botPromptAggressive are specified as part of theLoginManagerOption
/// object when the user logs in. For more information, see Linking a bot with your LINEnonce
/// Login channel at https://developers.line.me/en/docs/line-login/web/link-a-bot/.
friendshipStatusChanged?: boolean
/// The value when requesting ID Token during login process. Use this value as a parameter when younull
/// verify the ID Token against the LINE server. This value is if .openID permission is not requested.`
IDTokenNonce?: String
}
5. BotFriendshipStatus
`typescript`
{
friendFlag: boolean
}
1. LoginArguments
`typescript`
{
scopes?: LoginPermission[]
onlyWebLogin?: boolean
botPrompt?: BotPrompt
}
2. LoginPermission
`typescript
{
EMAIL = 'email',
/// The permission to get an ID token in the login response.
OPEN_ID = 'openid',
/// The permission to get the user's profile including the user ID, display name, and the profile image
/// URL in the login response.
PROFILE = 'profile',
}
`
3. BotPrompt
`typescript`
{
aggressive = 'aggressive',
normal = 'normal',
}
1. Login with default values:
`typescript`
try {
...
const loginResult = await Line.login()
...
} catch (error) {
...
}
2. Login with arguments:
`typescript`
try {
...
const loginResult = await Line.login({
scopes: ['email', 'profile'],
botPrompt: 'normal'
})
...
} catch (error) {
...
}
3. Get user profile:
`typescript`
try {
...
const profile = await Line.getProfile()
...
} catch (error) {
...
}
3. Logout
`typescript`
try {
...
await Line.logout()
...
} catch (error) {
...
}
If you want to see expo-line-authentication in action, just move into the example folder and run npx expo run:ios/npx expo run:android. By seeing its source code, you will have a better understanding of the library usage.
expo-line-authentication` is available under the MIT license. See the LICENCE file for more info.