Comments (7)
Oh, I will have to take a closer look at this. I'll try to find some time this weekend. Thank you for this report.
Does it work on Android?
from capacitor-firebase-authentication.
@robingenz Update on Twitter Auth:
I was able to grab information from that super complex deeplink return URL (took me a couple of hours... 😅 ):
function getTwitterToken(url: string): { token: null | string; verifier: null | string } {
if (!isFullString(url)) {
return { token: null, verifier: null }
}
/**
* @example "com.googleusercontent.apps.625543939572-45clgsm7vau24eualpnu9slvpst8lbcp://firebaseauth/link?deep_link_id=https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fcallback%3FauthType%3DsignInWithRedirect%26link%3Dhttps%253A%252F%252Fcolorfulcasting-22977.firebaseapp.com%252F__%252Fauth%252Fhandler%253Fstate%253DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%2526oauth_token%253Di5AwREDACTEDfFjLB8c%2526oauth_verifier%253DVREDACTEDzdSpsiYfQ%26eventId%3Dsifmpamdqx"
*/
const _url = url
/**
* @example "com.googleusercontent.apps.625543939572-45clgsm7vau24eualpnu9slvpst8lbcp://firebaseauth/link?deep_link_id=https://colorfulcasting-22977.firebaseapp.com/__/auth/callback?authType=signInWithRedirect&link=https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fhandler%3Fstate%3DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%26oauth_token%3Di5AwREDACTEDfFjLB8c%26oauth_verifier%3DVREDACTEDzdSpsiYfQ&eventId=sifmpamdqx"
*/
const urlUtf8 = decodeURIComponent(_url)
/**
* @example "deep_link_id=https://colorfulcasting-22977.firebaseapp.com/__/auth/callback?authType=signInWithRedirect&link=https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fhandler%3Fstate%3DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%26oauth_token%3Di5AwREDACTEDfFjLB8c%26oauth_verifier%3DVREDACTEDzdSpsiYfQ&eventId=sifmpamdqx"
*/
const outerQuery = urlUtf8.split('?').slice(1).join('?')
/**
* @example "https://colorfulcasting-22977.firebaseapp.com/__/auth/callback?authType=signInWithRedirect&link=https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fhandler%3Fstate%3DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%26oauth_token%3Di5AwREDACTEDfFjLB8c%26oauth_verifier%3DVREDACTEDzdSpsiYfQ&eventId=sifmpamdqx"
*/
const deepLinkId = outerQuery.replace(/.*deep_link_id=([^=]+)/, '$1')
/**
* @example "authType=signInWithRedirect&link=https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fhandler%3Fstate%3DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%26oauth_token%3Di5AwREDACTEDfFjLB8c%26oauth_verifier%3DVREDACTEDzdSpsiYfQ&eventId=sifmpamdqx"
*/
const innerQuery = deepLinkId.split('?')[1]
/**
* @example "https%3A%2F%2Fcolorfulcasting-22977.firebaseapp.com%2F__%2Fauth%2Fhandler%3Fstate%3DAMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ%26oauth_token%3Di5AwREDACTEDfFjLB8c%26oauth_verifier%3DVREDACTEDzdSpsiYfQ"
*/
const linkOfInnerQuery = innerQuery.replace(/.*link=([^&]+)(&.*|)/, '$1')
/**
* @example "https://colorfulcasting-22977.firebaseapp.com/__/auth/handler?state=AMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ&oauth_token=i5AwREDACTEDfFjLB8c&oauth_verifier=VREDACTEDzdSpsiYfQ"
*/
const linkUtf8 = decodeURIComponent(linkOfInnerQuery)
/**
* @example "state=AMbdREDACTEDnS-IYlUFuREDACTEDnn-xZssQfy-obREDACTEDjrlg_MfILVwREDACTEDwtEbkpL0l5a9RBrmDvn1DrFhgPQ&oauth_token=i5AwREDACTEDfFjLB8c&oauth_verifier=VREDACTEDzdSpsiYfQ"
*/
const linkQuery = linkUtf8.split('?')[1] || ''
const token = linkQuery.replace(/.*oauth_token=([^&]+)(&.+|)/, '$1')
const verifier = linkQuery.replace(/.*oauth_verifier=([^&]+)(&.+|)/, '$1')
console.log(`_url → `, _url)
console.log(`urlUtf8 → `, urlUtf8)
console.log(`outerQuery → `, outerQuery)
console.log(`deepLinkId → `, deepLinkId)
console.log(`innerQuery → `, innerQuery)
console.log(`linkOfInnerQuery → `, linkOfInnerQuery)
console.log(`linkUtf8 → `, linkUtf8)
console.log(`linkQuery → `, linkQuery)
console.log(`token → `, token)
console.log(`verifier → `, verifier)
return { token, verifier }
}
However, having this "verifier" seems not enough. It's not the "secret":
async function signinWithTwitterToken(token: string, verifier: string): Promise<void> {
const credential = TwitterAuthProvider.credential(token, verifier)
await signInWithCredential(firebaseAuth, credential)
}
When I execute this I got:
I'm not sure what to do next. : S
from capacitor-firebase-authentication.
@robingenz On Android it works as expected:
I get the proper info from your Library. So it must be just an iOS bug.
from capacitor-firebase-authentication.
@robingenz I did some more digging and found this line:
self.pluginImplementation.handleSuccessfulSignIn(credential: credential, idToken: nil, nonce: nil)
I technically can't read Swift, so I'm not 100% sure, but to me this looks like you pass null
for the idToken
and nonce
.
Your Twitter implementation is OAuth based and requires an "accessToken" and "secret", so I guess you need to write extra code and properly pass them to the handleSuccessfulSignIn
?
I guess you just overlooked it? 😅
from capacitor-firebase-authentication.
Thanks for looking it up.
The access token and secret should be added here.
So it is correct that I pass nil
there, because I can pick it up later.
I may find some time this weekend to debug this.
from capacitor-firebase-authentication.
@robingenz let me know if there's anything I can help you with this weekend.
from capacitor-firebase-authentication.
I just took a closer look.
It seems that the access token and the secret are added to the credential
object only after the native authentication.
The Firebase documentation includes the following example:
provider.getCredentialWith(nil) { credential, error in
if error != nil {
// Handle error.
}
if credential != nil {
Auth.auth().signIn(with: credential) { authResult, error in
if error != nil {
// Handle error.
}
// User is signed in.
// IdP data available in authResult.additionalUserInfo.profile.
// Twitter OAuth access token can also be retrieved by:
// authResult.credential.accessToken
// Twitter OAuth ID token can be retrieved by calling:
// authResult.credential.idToken
// Twitter OAuth secret can be retrieved by calling:
// authResult.credential.secret
}
}
}
As far as I know there is nothing I can do about it. For this reason, I am closing this Issue.
However, I have found a workaround:
I was able to log in with the Firebase JS SDK after setting skipNativeAuth
to false
. So you first log in natively to Firebase and then to the web. Unfortunately this does not work with all providers, since you can't use credentials twice with some providers. Therefore I don't know if this is a workaround for you.
I could imagine extending the skipNativeAuth
option to allow configuration for individual providers. However, for this I would create a new feature request.
from capacitor-firebase-authentication.
Related Issues (20)
- bug: Error: invalid credential when signInWithCredential using idToken after closing & re-opening app HOT 2
- Info about how to add firebase app HOT 3
- bug: Facebook returns no email adress HOT 6
- bug: angular fire guards doesnt' work on mobile HOT 7
- bug: getCurrentUser returns undefined user HOT 2
- feat: Convert an anonymous account to a permanent account HOT 2
- Login persistent , I have to sigin everytime with the phone number and otp , but firebase uses cookies to persist tokens , make that auto sigin . HOT 1
- I would like to get the usage of firebase storage, how can i implement , there is no auth provided , i am talking about with the security rules ( allow read, write: if request.auth != null ) HOT 1
- bug: Resend otp in phone auth ? HOT 1
- bug: SignInOptions not working HOT 2
- bug:
- bug: iOS Sign in Not Persisting HOT 1
- bug: `addListener('authStateChange', ...)` callback is never get called HOT 9
- bug: Firebase Instance ID Depreciation warning HOT 6
- bug: hard crash after calling signInWithPhoneNumber HOT 1
- bug: Sign back in with Apple - Duplicate User HOT 11
- bug: reCAPTCHA shows an error after release. This request is missing a valid app identifier HOT 2
- bug: not compatible with other firebase community plugins HOT 5
- bug: iOS directions fail to install required Firebase pods for M1 Mac HOT 1
- bug: Issue with Facebook SignIn accessToken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capacitor-firebase-authentication.