useDynamicContext()
hook to access authentication methods and states.environmentID
and publicKey
from the developer page and store them somewhere accessible. These will be used later on in the app.environmentId
obtained previously.
You can read more about DynamicContextProvider here.
useDynamicContext()
hook to get all the context that our app needs from Dynamic. A comprehensive set of methods and variables available from useDynamicContext()
can be found here.
onClick
for this button calls the setShowAuthFlow
function that was returned from useDynamicContext
. Using a couple of lines, we have successfully added a straightforward authentication mechanism to our app!
authenticateJWT
function will be used in our backend to create the user and wallet using Co:Create APIs. Here we verify that the token is valid and extract the email address.
We use the email address to send a POST request to the Co:Create user creation API endpoint. Docs on the Co:Create User APIs can be found here. We will return the response from the creation API endpoint back to the client. This response should contain the Co:Create wallet address for the user.
DYNAMIC_API_KEY=dyn_XXXXXXXXXXXXXXXXXXXXXXXXXX
.
You can then use axios
to send a POST request to Dynamic to associate the Co:Create Wallet Address with Dynamic’s user profile.