gurisko / cordova-plugin-accountkit

AccountKit Plugin for Apache Cordova which allows you to add passwordless email and SMS authentication to your app
MIT License
34 stars 42 forks source link

getAccount doesnt work #27

Open khouleBousso opened 7 years ago

khouleBousso commented 7 years ago

Hi, everyone. Thanks for this plugin. It's very helpul.

I use it in my ionic2 app. But when i use the function getAccount after the phone authentification, it sends me an implicit error. I don't know what. please refers to my Code :+1:

   AccountKitPlugin.loginWithPhoneNumber(options,
         (response) => {
           AccountKitPlugin.getAccount(
             (response) =>
             {
               console.log(response)
             },
             (error) =>{
               throw error // here the thrown error
             }
           )

         },
         (error: any) => console.error(error)
       );
gurisko commented 7 years ago

I was unable to reproduce this. Is there a way you make a separate repo where this can be reproduced? @khouleBousso

gurisko commented 7 years ago

@khouleBousso Would you have any chance to retest this issue with the latest version (v1.3.0)?

khouleBousso commented 7 years ago

@gurisko ok i try this and give u a feedback

trivielldev commented 7 years ago

@gurisko We're trying to use getAccount to see if a user has signed in with AccountKit. Our assumption was that this would return an error if user was not logged in. For iOS it doesn't return or do anything, so the method below will NOT return true or false. Seems to be working like expected on Android.

isAuthenticated() {
    AccountKitPlugin.getAccount((response) => {
      console.log("Success", response);
      return true;
    }), (error) => {
      console.log("Error", error);
      return false;
    }
  }

Thanks for your input.

gurisko commented 7 years ago

It should work as you assume. Are you using the latest v1.3.0?

On 1 Aug 2017 6:50 p.m., "Simon Litlehamar" notifications@github.com wrote:

@gurisko https://github.com/gurisko We're trying to use getAccount to see if a user has signed in with AccountKit. Our assumption was that this would return an error if user was not loggen in. For iOS it doesn't return or do anything. Seems to be working like expected on Android.

isAuthenticated() { AccountKitPlugin.getAccount((response) => { console.log("Success", response); return true; }), (error) => { console.log("Error", error); return false; } }

Thanks for your input.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/gurisko/cordova-plugin-accountkit/issues/27#issuecomment-319429591, or mute the thread https://github.com/notifications/unsubscribe-auth/AAePvV9CZCBhhaa9fOsLGcrZkAiBLRKKks5sT1dIgaJpZM4OQvgB .

trivielldev commented 7 years ago

Yes, we're using the latest version. Did some digging in the iOS code and it seems like the _accountKit variable is still nil if the login hasn't been initiated once before we call the getAccount-method, so it just skips over the call to _accountKit requestsAccount.

trivielldev commented 7 years ago

Two things wrong. First, the javascript code posted was not correct. Correct version

AccountKitPlugin.getAccount((response) => {
      console.log("Success", response);
      return true;
    }, (error) => {
      console.log("Error", error);
      return false;
    });

Second, there is no callback triggered from the iOS plugin if you call the getAccount method before using login-method (instantiating the _accountKit variable). Added a suggested fix to PR #34

khouleBousso commented 7 years ago

Hi,

I am not unable to verify the new access token generated by your 1.3.0 version on graph api https://graph.accountkit.com/v1.2/me/?access_token='+accessToken.

I get a : "Invalid OAuth access token"

Eman-Shaaban commented 6 years ago

Still doesn't work, @gurisko : any news? Is this PR (https://github.com/gurisko/cordova-plugin-accountkit/pull/43) related to this issue??

lilian131 commented 6 years ago

hello I have the same error Server generated an error did you figure out how to do ?