I'm setting up an expo application with a local docker keycloak server. I followed the expo step-by-step, and after calling the promptAsync method, I've got a type: success response. However, I'm not receiving any token. This is my request result.
** prompAsync result**
{
"authentication":null,
"error":null,
"errorCode":null,
"params":{
"code":"6d054370-129b-43cf-8a50-4d9b66d71ee7.5e0ae876-fee5-49f7-ac89-9dbf03c1c620.b3055e80-ee68-4a53-b118-788efca721fe",
"session_state":"5e0ae876-fee5-49f7-ac89-9dbf03c1c620",
"state":"R6H8w3tArj"
},
"type":"success",
"url":"myapp://home?state=R6H8w3tArj&session_state=5e0ae876-fee5-49f7-ac89-9dbf03c1c620&code=6d054370-129b-43cf-8a50-4d9b66d71ee7.5e0ae876-fee5-49f7-ac89-9dbf03c1c620.b3055e80-ee68-4a53-b118-788efca721fe"
}
I know that in the standard authorization flow, we receive a verified code which we exchange for a toke with the server. How can I request this token?
This is my implementation:
const Login = () => {
WebBrowser.maybeCompleteAuthSession()
const discovery = useAutoDiscovery(`${SERVER_URL}realms/${REALM}`)
const [request, result, promptAsync] = useAuthRequest(
{
clientId: CLIENT_ID,
redirectUri: makeRedirectUri({
scheme: APP_SCHEME,
path: 'home',
}),
scopes: ['openid', 'profile'],
},
discovery
)
const handleOnPress = async () => {
try {
const response = await promptAsync()
console.log('login response: ', response)
console.log('result: ', result)
} catch (e) {
console.log('login error: ', e)
}
}
console.log({ result })
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Button
title="Login!"
onPress={() => {
handleOnPress()
}}
disabled={!request}
/>
{/* {result && <Text>{JSON.stringify(result, null, 2)}</Text>} */}
</View>
)
}