You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I'm trying to do is to create a native module which will handle signin process.
I want to pass props to this native module and handle the response/errors of the signing proces. The main goal is to get idToken from the response.
I created a native module via npx create-expo-module klarna-auth. It creates a template for native module and example folder where I can test it with all predefined settings. The template works well.
Then I defined an Event Handler. I took this code from the Klarna signIn docs as well:
package expo.modules.klarna
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
class KlarnaAuthModule : Module() {
override fun definition() = ModuleDefinition {
Name("KlarnaAuth")
Function("getTheme") {
return@Function "system"
}
}
private val eventHandler = object : KlarnaEventHandler {
override fun onEvent(klarnaComponent: KlarnaComponent, event: KlarnaProductEvent) {
when(event.action) {
KlarnaSignInEvent.USER_TAPPED_BUTTON -> {
// User tapped the KlarnaSignInButton, auth process starting
}
KlarnaSignInEvent.USER_AUTH -> {
// User completed interactive auth, tokens will be fetched
}
KlarnaSignInEvent.USER_CANCELLED -> {
// User manually canceled sign in
}
KlarnaSignInEvent.SIGN_IN_TOKEN -> {
// User is authorized. You can read the results
// in event.params attribute by casting it to the
// KlarnaSignInToken model.
val token = event.params[KlarnaSignInEvent.ParamKey.KlarnaSignInToken] as? KlarnaSignInToken
val accessToken = token?.accessToken
// Handle the access token
}
}
}
override fun onError(klarnaComponent: KlarnaComponent, error: KlarnaMobileSDKError) {
// In case of any errors, check the 'error' parameter for more details,
// for example if the error is fatal or not.
val errorMessage = error.message
val isFatal = error.isFatal
when(error.name) {
KlarnaSignInError.InvalidClientID -> {
// The client ID value is invalid
}
KlarnaSignInError.InvalidScope -> {
// The scope value is invalid
}
KlarnaSignInError.InvalidMarket -> {
// The market value is invalid
}
KlarnaSignInError.InvalidCustomTabsReturnUrl -> {
// The AndroidManifest needs to be set up for KlarnaCustomTabActivity
}
KlarnaSignInError.SignInFailed -> {
// User authorization step failed
val signInError = error.params[KlarnaSignInError.ParamKey.Error]
val signInErrorDescription = error.params[KlarnaSignInError.ParamKey.ErrorDescription]
}
KlarnaSignInError.RenderButtonFailed -> {
// Button failed to render
}
KlarnaSignInError.AlreadyInProgress -> {
// Sign in is already in progress, user tap or signIn method call is ignored
}
}
}
}
}
Then I ran npm run build in native module folder('klarna-auth').
And then ran npx expo run:android in example folder to test the module.
Looks like i need link/install Klarna signin sdk, but I don't understand how to do it. Need your help.
The text was updated successfully, but these errors were encountered:
mikeAdutskevich
changed the title
Issue with Klarna signin integration in my expo
Issue with Klarna signin integration in my expo51
Dec 12, 2024
mikeAdutskevich
changed the title
Issue with Klarna signin integration in my expo51
Issue with Klarna signin integration in my expo51 via native module
Dec 18, 2024
I'm having issues with Klarna signin integration in my expo(v51.0.0) project.
I use expo managed workflow with dev-builds.
The Klarnas' documentation:
https://docs.klarna.com/conversion-boosters/sign-in-with-klarna/integrate-sign-in-with-klarna/mobile-integration/
What I'm trying to do is to create a native module which will handle signin process.
I want to pass props to this native module and handle the response/errors of the signing proces. The main goal is to get idToken from the response.
I created a native module via
npx create-expo-module klarna-auth
. It creates a template for native module andexample
folder where I can test it with all predefined settings. The template works well.Then I go to Android klarna integration and updated AndroidManifest.xml with:
This not causing errors at least now.
Then I defined an Event Handler. I took this code from the Klarna signIn docs as well:
Then I ran
npm run build
in native module folder('klarna-auth').And then ran
npx expo run:android
in example folder to test the module.And got the error:
Looks like i need link/install Klarna signin sdk, but I don't understand how to do it. Need your help.
The text was updated successfully, but these errors were encountered: