Ty
I got it working with
expo-auth-session
Code:
const clientId = Line.channelId // your line channel id
const scope = 'profile%20openid%20email' // 'profile%20openid%20'
const state = Math.random().toString(36).substring(2, 15)
const projectNameForProxy = '@owner/slug' // change to your owner/slug
const authEndpoint = 'https://access.line.me/oauth2/v2.1/authorize'
const redirectUri = makeRedirectUri({
scheme: Application.applicationId,
useProxy: true,
projectNameForProxy
})
const authUrl = `${authEndpoint}?response_type=code&client_id=${clientId}&redirect_uri=${redirectUri}&state=${state}&scope=${scope}`
const result = await startAsync({ authUrl, projectNameForProxy })
console.log(JSON.stringify(result))
Also add the line account that you're using to test this login in your line developer console under "Roles" section.
Michael Wood
Merged in a post:
Line login
Bond Piyapan
Im use Line login with expo-auth-session
with expo-dev-client
has issue 'Something went wrong trying to finish signing in. Please close this screen to go back to the app.'
my code :
const discovery = {
authorizationEndpoint: 'https://access.line.me/oauth2/v2.1/authorize',
}
const [request, result, promptAsync, response] = useAuthRequest(
{
scopes: ['profile', 'openid'],
clientId: '123456',
clientSecret: '12345',
responseType: 'code',
redirectUri: makeRedirectUri({
scheme: 'com.app.app',
useProxy: true,
}),
},
discovery,
)
useEffect(() => {
// TODO Line login
console.log('response', response)
console.log('result', result)
console.log('request', request)
}, [response, result])
Please help thank you.
Scott Pritchard
I'd suggest using https://github.com/xmartlabs/react-native-line combined with EAS. Alternatively, they do have an oAuth compatible API (https://developers.line.biz/en/docs/line-login/integrate-line-login/) so it should be workable with https://docs.expo.io/versions/latest/sdk/auth-session/
Dai Dang
Scott Pritchard: Alternatively, they do have an oAuth compatible API (https://developers.line.biz/en/docs/line-login/integrate-line-login/) so it should be workable with https://docs.expo.io/versions/latest/sdk/auth-session/
=> is this possible?
Scott Pritchard
Dai Dang: Give it a try and let us know?
Dai Dang
Scott Pritchard: yes, thanks for your suggestion
Dai Dang
Scott Pritchard: on line-developers, we need setup callback-url
However, the url of expo is like ( exp://192.168.1.139:19000/+/redirect )
This url is invalid for LINE Callback-url
i'm confused!
Michael Wood
Dai Dang: Some authentication servers might not allow redirects to anything other than https://...
Also, redirects to Expo Go could be problematic.
There's a proxy service that is used to get around this sort of stuff, but not sure exactly how you use it if you're implementing LINE authentication. Maybe this will help, although it's talking about the Bare workflow: https://docs.expo.dev/versions/latest/sdk/auth-session/#proxy-service
See also https://docs.expo.dev/guides/linking/#example-using-linking-for-authentication and the next section.
Dai Dang
Michael Wood:
I will try it!
Thank you very much!