Closed kamalpandey closed 1 year ago
@kamalpandey I plan on having this working tonight, and I'm forking to write docs now. I'll keep you posted.
Quick overview:
0) devise + doorkeeper + oidc + pkce 1) react-native-app-auth 2) fetch + Authorization header 3) omniauth apple setup 4) profit
@skotchpine any luck?
Oh yeah, no problem!
I know this doesn't answer MOST of this issue, but I think it answers covers the scope of this library #62
@skotchpine's guide does an excellent job of how to setup the library. I just wanted to expand on the final part, how to sync in-app credentials with the omniauth backend.
You need to pass some variables back to the omniauth callback endpoint.
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL],
});
// get current authentication state for user
// /!\ This method must be tested on a real device. On the iOS simulator it always throws an error.
const credentialState = await appleAuth.getCredentialStateForUser(appleAuthRequestResponse.user);
// use credentialState response to ensure the user is authenticated
if (credentialState === appleAuth.State.AUTHORIZED) {
// HERE:
const serverResponse = await apiClient.perform("GET", "https://yourserver/auth/apple/callback", {
type: "json",
queryParams: {
code: appleAuthRequestResponse.authorizationCode,
state: appleAuthRequestResponse.state,
id_token: appleAuthRequestResponse.identityToken,
nonce: appleAuthRequestResponse.nonce,
user: JSON.stringify({
email: appleAuthRequestResponse.email
})
}
});
if (serverResponse.success) {
alert("Done")
}
}
Replace apiClient.perform
with your preferred way of sending requests to your server (fetch
for example).
I'd also like to add that I have been very pleased with this library: https://github.com/FormidableLabs/react-native-app-auth
I think this issue is really out of scope for this library. If you'd like more advice, I'd be glad to do a call. My email is: tycinnamon@gmail.com
To be clear: I'd recommend closing the issue.
I have done this a few times. The documentation here is lacking