- React
- React Native
- Javascript
- Swift
- Flutter
You can use the After this point, you can use the Dynamic SDK to access the user’s profile and other data, just as you would with any other user.
signInWithExternalJwt method from the useExternalAuth hook.React
Copy
Ask AI
const { signInWithExternalJwt } = useExternalAuth();
try {
// `externalUserId`: User ID in the external auth system
// `externalJwt`: Raw encoded JWT issued by external auth system
const userProfile = await signInWithExternalJwt({
externalUserId,
externalJwt
});
if (userProfile) {
// You should be logged in at this point
}
} catch (e: any) {
console.error('Dynamic login failed:', e);
}
React Native provides external authentication through the dynamic client’s auth methods.After this point, you can use the Dynamic SDK to access the user’s profile and other data, just as you would with any other user.
React Native
Copy
Ask AI
import { dynamicClient } from '<path to client file>';
try {
// `externalUserId`: User ID in the external auth system
// `externalJwt`: Raw encoded JWT issued by external auth system
await dynamicClient.auth.external.signInWithExternalJwt({
externalUserId,
externalJwt
});
// You should be logged in at this point
} catch (e: any) {
console.error('Dynamic login failed:', e);
}
Copy
Ask AI
import { signInWithExternalJwt } from '@dynamic-labs-sdk/client';
const signIn = async (yourExternalJwt) => {
await signInWithExternalJwt({ externalJwt: yourExternalJwt });
// User is now authenticated
};
Coming soon
Flutter provides external authentication through the Dynamic SDK’s auth methods.After this point, you can use the Dynamic SDK to access the user’s profile and other data, just as you would with any other user.You can also use
Flutter
Copy
Ask AI
import 'package:dynamic_sdk/dynamic_sdk.dart';
try {
// `externalUserId`: User ID in the external auth system
// `externalJwt`: Raw encoded JWT issued by external auth system
await DynamicSDK.instance.auth.externalAuth.signInWithExternalJwt(
SignInWithExternalJwtParams(
externalJwt: externalJwt,
externalUserId: externalUserId,
),
);
// You should be logged in at this point
} catch (e) {
print('Dynamic login failed: $e');
}
verifyWithExternalJwt to verify a user:Flutter
Copy
Ask AI
import 'package:dynamic_sdk/dynamic_sdk.dart';
try {
await DynamicSDK.instance.auth.externalAuth.verifyWithExternalJwt(
VerifyWithExternalJwtParams(
externalJwt: externalJwt,
externalUserId: externalUserId,
),
);
// User is now verified
} catch (e) {
print('Verification failed: $e');
}