-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get AdditionalUserInfo ? #23
Comments
Hi. I think that is better to just return capacitor-firebase-auth/src/facades.ts Line 78 in 60b86da
And here, at cfaSignIn method, we could use SignInOptions. capacitor-firebase-auth/src/facades.ts Line 22 in 60b86da
New Pull Request ?So If this is not bad idea, Do you need new pull request ? If that so, I will write code for user options like this way. what do you think about this way? (Sorry, I am not professional ) |
Hi ! As I'm not professional and new to typescript, for now, I simply added below code for get This work fine for me. If you can advise me for improve my code, I update my code and send you pull request. @baumblatt |
Hi Go-U, I understand your needs, but in my opinion, it’s better to keep the facade equals for every authentication provider. But please, keep in my that this is only the facade, you can use the plugin directly exactly in the same way as the facade do. In other words, your version of Anyway, take a look at this answer in stackoverflow about getting user info after user sign in. Please let me know if you have any questions, or we can close this issue. Best regards, |
Thank you for your very polite reply. I now think that there is no need to add functionality for "AdditionalUserInfo". However, I think we need a way to handle Twitter Now, Let me explain a specific example. ExampleI am currently using a method similar to the one you introduced, There are This is done using the GET followers / list endpoint. If this endpoint is used with "app auth", the rate limit will be reached immediately and the app will not function. On the other hand, "user auth" can use this endpoint up to 15 times in 15 minutes, but Rate Limit is calculated for each user. I think that it is common to use "user auth" when making a Twitter application. QuestionIn this way, most Twitter apps seem to require a Twitter user's access token and secret, capacitor-firebase-auth/src/facades.ts Line 78 in 60b86da
Thank you again for a very polite reply. |
Hi Go-U, The answer is yes, there is, but the point of doubt is: Should we add this feature to the Javascript facade of the plugin? On my opinion, we should keep it simple on behalf of the major of plugin users. But is very simple to implement your own call to the plugin, that as you mention already return the TwitterSignInResult from the roots. You can put this snippet anywhere in your App, without any change in the plugin itself. import {TwitterSignInResult} from 'capacitor-firebase-auth';
import {CapacitorFirebaseAuthPlugin} from 'capacitor-firebase-auth/dist/esm/definitions';
// @ts-ignore
const plugin: CapacitorFirebaseAuthPlugin = Plugins.CapacitorFirebaseAuth;
/**
* Call the Twitter sign in method on native and sign in on web layer with retrieved credentials and
* return the twitter credentials and the firebase user.
*/
export const myCfaSignInTwitter = (): Observable<firebase.User> => {
return new Observable(observer => {
// get the provider id
const providerId = firebase.auth.TwitterAuthProvider.PROVIDER_ID;
// native sign in
plugin.signIn({providerId}).then((result :TwitterSignInResult) => {
// create the credentials
const credential = firebase.auth.TwitterAuthProvider.credential(result.idToken, result.secret);
// web sign in
firebase.app().auth().signInWithCredential(credential)
.then((userCredential: firebase.auth.UserCredential) => {
observer.next({
credentials: {idToken: result.idToken, secret: result.secret}
user: userCredential.user,
});
observer.complete();
})
.catch((reject: any) => observer.error(reject));
}).catch(reject => observer.error(reject));
});
}; In the next release I will expose the CapacitorFirebaseAuthPlugin, in a way that the deeper import could be avoided. Finally, if you still thing that the facade’s plugin should do the job, I’m willing to expose the method above with a better name. I’m looking forward to hearing from you. Best regards, |
Thank you for the detailed explanation with code !
If the meaning of this explanation is to make it easy to receive the “Twitter's user's access token and secret ” in Javascript, I think that is a great feature. ReasonsThe reason why I think it is great feature to receive "Twitter's user's access token and secret" in Javascript is as follows. SupplementI live in Japan, where Twitter is very popular and maintains a world record of tweets per second. 143,199TPS (143K Tweet / Sec.) Twitter's user's access token and secret (user auth) is required for the above reasons. My opinionFor the above reasons, at least Japanese developers I know want to easily receive “Twitter user's access token and secret” in Javascript. Finally, thanks for writing a great plugin. |
Hi Go-U, Ok, let's do it! Last two questions before start coding:
Best regards, |
Hi baumblatt, thanks your reply !
Thank you! Super great news!
I am not a professional programmer. plug-in users use case
Implementation points for Twitter API and Facebook APITwitter (I have experienced myself)Need user's access token and secret included in TwitterSignInResult Need Only access token included in FacebookSignInResult. Key pointsWhen developing dedicated functions using Twitter or Facebook APIs within the app, separate implementations are required for each API. Conclusion (if I choose one of the dedicated methods or options)Developers need to implement separate code for Facebook and Twitter APIs. If that is the case, I think that the convenience of the person developing the Plugin is important. In terms of ease of code maintenance, I think it is best to implement it in an optional form. Supplementary conclusion (if there is a third option)
|
Hi baumblatt, thank you very much for adding the code! Currently trying out new code. New code works great !! But small import error occur.
And error is this.
And I tried above notice command
And I change import part like this. Then, no error. Your plugin works perfectly !! But do you need more information on the above import errors? Finally, thank you again! |
Hi Go-u,
I think is better to keep this issue opened until we got everything working
as expected.
During my tests, I had the same problem, but in typescript was fixed with a
package.json inside the alternative folder.
I will take a look, what is needed to solve this in vanilla script too.
As soon as I have news, I will share it with you.
Please, if you have any ideas on how to solve it, let me know.
Best regards,
Bernardo Baumblatt.
…On Mon, Oct 14, 2019, 12:26 go-u ***@***.***> wrote:
Hi baumblatt, thank you very much for adding the code!
Currently trying out new code. New code works great !!
But small import error occur.
The import part looks something like this. I'm using javascript. Not
typescript.
import { cfaSignInTwitter } from 'capacitor-firebase-auth/alternative'
And error is this.
This dependency was not found:
* capacitor-firebase-auth/alternative in ./src/store/auth/actions.js
To install it, you can run: npm install --save
capacitor-firebase-auth/alternative
Module not found: Error: Can't resolve
'capacitor-firebase-auth/alternative' in......
And I tried above notice command npm install --save
capacitor-firebase-auth/alternative.
Then, this message shown....
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://
***@***.***/capacitor-firebase-auth/alternative.git
npm ERR!
npm ERR! ERROR: Repository not found.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
And I change import part like this.
import { cfaSignInTwitter } from
'capacitor-firebase-auth/dist/esm/alternative'
Then, no error. Your plugin works perfectly !!
So, I want to close this issue later.
But do you need more information on the above import errors?
Or do I need to close this issue thread as soon as possible?
Finally, thank you again!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23?email_source=notifications&email_token=ADJMCV7IBAIGJROIAB37ESLQOSFRPA5CNFSM4IYLB7TKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBFGHLA#issuecomment-541746092>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADJMCV4NSY6RIYOHYUODS5LQOSFRPANCNFSM4IYLB7TA>
.
|
Hi Go-u, The version 0.2.4 is out there with a little typo fixed that maybe solve the import issue. I looking forward to hearing about your tests. Best regards, |
Hi baumblatt, thank you for your update ! The update works almost perfectly! (Tried However, a very small problem remains. (Or is this my mistake?) My code
Then, console.log(userCredential) displayed this
Then, console.log(result) displayed this
I tried both cfaSignIn ('twitter.com') method and cfaSignInTwitter method. Since version 0.2.4 is not released on Github, I could not find out the cause. Thanks ! |
This is a postscript I'm sorry. In Firebase, I found that the following is officially called
So the above comment was my mistake. I'm sorry. I will close this issue as soon as version 0.2.4 is added on Github. |
Hi Go-U, Sorry about, I forgot to push the last changes. Now, it’s all there. Best regards, |
Hi! Thank you for very nice app !!
I want to get below info from twitter login user .
screen_name
/name
/description
/profile_image_url_https
/profile_banner_url
I think
result.additionalUserInfo.profile
contain these info. How can I get this ?Maybe here, this
result
containresult.additionalUserInfo.profile
.capacitor-firebase-auth/src/facades.ts
Line 78 in 60b86da
But only return
userCredential.user
here ? right ?capacitor-firebase-auth/src/facades.ts
Line 85 in 60b86da
The text was updated successfully, but these errors were encountered: