capacitor-community / facebook-login

Facebook Login support
MIT License
103 stars 54 forks source link

E/GraphResponse Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons #44

Closed BresciMa closed 3 years ago

BresciMa commented 3 years ago

Hi Folks!! I´m trying to implement this Facebook Login in my Ionic Capacitor APP.

Describe the bug

const result = await FacebookLogin.login(['email']);

But i have nothing in the response, and it return false : if (result.accessToken) {

Some Important points:

MainActivity.java Was changed and added : add(jp.rdlabo.capacitor.plugin.facebook.FacebookLogin.class);

AndroidManifest.xml was changed

Using: "@angular/common": "~11.2.13", "@angular/core": "~11.2.13", "@angular/fire": "^6.1.4", "@angular/forms": "~11.2.13", "@angular/platform-browser": "~11.2.13", "@angular/platform-browser-dynamic": "~11.2.13", "@angular/router": "~11.2.13", "@capacitor/android": "^2.4.3", "@capacitor/core": "2.4.3", "@ionic-native/core": "^5.32.1", "@ionic-native/facebook": "^5.32.1", "@ionic-native/push": "^5.32.1", "@ionic-native/splash-screen": "^5.32.1", "@ionic-native/status-bar": "^5.32.1", "@ionic/angular": "^5.6.6", "@rdlabo/capacitor-facebook-login": "^2.0.3", "async-mutex": "^0.2.6", "cordova-plugin-facebook4": "^6.4.0", "es6-promise-plugin": "^4.2.2", "firebase": "^8.1.1", "globalthis": "^1.0.2", "ionic-rating": "^2.0.0", "phonegap-plugin-multidex": "^1.0.0", "rxjs": "~6.5.5", "tslib": "^2.2.0", "zone.js": "~0.10.3" I Just added the code:

And then the Run Result:

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 93895678, pluginId: FacebookLogin, methodName: login V/Capacitor: callback: 93895678, pluginId: FacebookLogin, methodName: login, methodData: {} D/Capacitor/FacebookLogin: Entering login() D/InputMethodManager: HSIFW - flag : 0 Pid : 26055 V/FA: Recording user engagement, ms: 67747 V/FA: Connecting to remote service W/com.facebook.appevents.AppEventsLoggerImpl: This function is deprecated. deactivate app will be logged automatically D/Capacitor: App paused W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@d543416 V/FA: onActivityCreated V/FA: Activity paused, time: 1990637269 D/PhoneWindow: forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4238 com.android.internal.policy.DecorView.updateColorViews:1491 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3216 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2444 I/MultiWindowDecorSupport: updateCaptionType >> DecorView@32a9c8f[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true D/MultiWindowDecorSupport: setCaptionType = 0, DecorView = DecorView@32a9c8f[] V/FA: Connection attempt already in progress V/FA: Activity resumed, time: 1990637346 V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress D/ViewRootImpl@b554729[FacebookActivity]: setView = com.android.internal.policy.DecorView@32a9c8f TM=true MM=false D/ViewRootImpl@903e594[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@2638045[MainActivity] getNavigationBarColor() -855310 D/ViewRootImpl@b554729[FacebookActivity]: Relayout returned: old=(0,0,720,1560) new=(0,0,720,1560) req=(720,1560)0 dur=16 res=0x7 s={true 513239728128} ch=true D/OpenGLRenderer: createReliableSurface : 0x76e3de0e80, 0x777f78c000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/ViewRootImpl@b554729[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.marceloj.open7 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus D/InputTransport: Input channel destroyed: 'ClientS', fd=176 D/ViewRootImpl@b554729[FacebookActivity]: MSG_RESIZED: frame=(0,0,720,1560) ci=(0,53,0,84) vi=(0,53,0,84) or=1 D/FA: Connected to remote service V/FA: Processing queued up service tasks: 4 V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 926 V/FA: Activity paused, time: 1990638276 D/ViewRootImpl@b554729[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] getNavigationBarColor() -855310 D/InputTransport: Input channel destroyed: 'ClientS', fd=171 D/FA: Application going to the background V/FA: Inactivity, disconnecting from the service I/System.out: (HTTPLog)-Static: isSBSettingEnabled false I/System.out: (HTTPLog)-Static: isSBSettingEnabled false D/ViewRootImpl@b554729[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.marceloj.open7 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus D/Capacitor/FacebookLogin: Entering handleOnActivityResult(64206, -1) D/Capacitor/FacebookLogin: LoginManager.onCancel onActivityResult succeeded D/ViewRootImpl@903e594[MainActivity]: stopped(false) old=false D/Capacitor/App: Firing change: true V/Capacitor/App: Notifying listeners for event appStateChange V/FA: Activity resumed, time: 1990652784 D/Capacitor/App: No listeners found for event appStateChange I/System.out: (HTTPLog)-Static: isSBSettingEnabled false (HTTPLog)-Static: isSBSettingEnabled false D/Capacitor: App resumed D/ViewRootImpl@903e594[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@2638045[MainActivity] getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@2638045[MainActivity] getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.marceloj.open7 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus D/InputTransport: Input channel destroyed: 'ClientS', fd=171 D/ViewRootImpl@b554729[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@32a9c8f[FacebookActivity] D/InputMethodManager: getNavigationBarColor() -855310 V/Capacitor/Network: Notifying listeners for event networkStatusChange D/Capacitor/Network: No listeners found for event networkStatusChange I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 149 - Msg: Rodou Facebook 2 I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 153 - Msg: Acima o conteúdo do result I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 184 - Msg: Response não trouxe nada... File: http://localhost/pages-login-login-module-es2015.js - Line 186 - Msg: Finalizando Facebook 2 I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 438 - Msg: LoginPage: loginUsingFacebook Sucesso no Login E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 439 - Msg: undefined D/ViewRootImpl@b554729[FacebookActivity]: stopped(true) old=false I/System.out: (HTTPLog)-Static: isSBSettingEnabled false (HTTPLog)-Static: isSBSettingEnabled false W/libEGL: EGLNativeWindowType 0x76e3de0e90 disconnect failed D/ViewRootImpl@b554729[FacebookActivity]: dispatchDetachedFromWindow D/InputTransport: Input channel destroyed: 'a762e93', fd=162 V/FA: Connecting to remote service V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 2 E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} V/FA: Inactivity, disconnecting from the service I/System.out: (HTTPLog)-Static: isSBSettingEnabled false I/System.out: (HTTPLog)-Static: isSBSettingEnabled false E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} I/System.out: (HTTPLog)-Static: isSBSettingEnabled false (HTTPLog)-Static: isSBSettingEnabled false E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.}

Could you Help me?

BresciMa commented 3 years ago

Hi folks!! I understood the migration of components from the rdlabo / to the capacitor-community / repository. For this reason I modified the project to update this issue.

I modified the dependency in the package.json to "@capacitor-community/facebook-login": "^2.0.0",

and my method was like this:

async loginByFacebookComunity() : Promise { const result : FacebookLoginResponse = await FacebookLogin.login({ permissions: ['email']}) ;

if (result.accessToken) {
  console.log('Facebook access token is ${result.accessToken.token}');
  console.log(result);
} else {
  console.log("Não funcionou o login")
}

}

and the result continued with the same error E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.}

This error does not happen with a specific user. It happens to any user who tries to login. Facebook's keys are apparently ok.

_I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 261 - Msg: Iniciando login com Facebook V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 56370507, pluginId: FacebookLogin, methodName: login V/Capacitor: callback: 56370507, pluginId: FacebookLogin, methodName: login, methodData: {"permissions":["email"]} D/Capacitor/FacebookLogin: Entering login() D/InputMethodManager: HSIFW - flag : 0 Pid : 30243 D/Capacitor: App paused V/FA: Recording user engagement, ms: 47459 V/FA: Connecting to remote service D/ViewRootImpl@a825e09[MainActivity]: dispatchDetachedFromWindow D/InputTransport: Input channel destroyed: 'ac9fcce', fd=159 W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@242b8da V/FA: Activity paused, time: 240554299 V/FA: onActivityCreated D/PhoneWindow: forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4238 com.android.internal.policy.DecorView.updateColorViews:1491 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3216 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2444 I/MultiWindowDecorSupport: updateCaptionType >> DecorView@4477000[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true D/MultiWindowDecorSupport: setCaptionType = 0, DecorView = DecorView@4477000[] V/FA: Connection attempt already in progress V/FA: Activity resumed, time: 240554465 D/ViewRootImpl@7e54b66[FacebookActivity]: setView = com.android.internal.policy.DecorView@4477000 TM=true MM=false D/ViewRootImpl@7e54b66[FacebookActivity]: Relayout returned: old=(0,0,720,1560) new=(0,0,720,1560) req=(720,1560)0 dur=15 res=0x7 s={true 525223354368} ch=true D/OpenGLRenderer: createReliableSurface : 0x7a57fac100, 0x7a49c06000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress D/ViewRootImpl@9f1e39d[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a1ce927[MainActivity] D/InputMethodManager: getNavigationBarColor() -855310 D/ViewRootImpl@7e54b66[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@4477000[FacebookActivity] getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@4477000[FacebookActivity] getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.marceloj.open7 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus D/InputTransport: Input channel destroyed: 'ClientS', fd=167 D/ViewRootImpl@7e54b66[FacebookActivity]: MSG_RESIZED: frame=(0,0,720,1560) ci=(0,53,0,84) vi=(0,53,0,84) or=1 D/FA: Connected to remote service V/FA: Processing queued up service tasks: 4 V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 866 V/FA: Activity paused, time: 240555332 D/ViewRootImpl@7e54b66[FacebookActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@4477000[FacebookActivity] D/InputMethodManager: getNavigationBarColor() -855310 D/InputTransport: Input channel destroyed: 'ClientS', fd=186 D/FA: Application going to the background V/FA: Inactivity, disconnecting from the service D/Capacitor/FacebookLogin: Entering handleOnActivityResult(64206, -1) D/Capacitor/FacebookLogin: LoginManager.onSuccess D/Capacitor/FacebookLogin: onActivityResult succeeded D/ViewRootImpl@9f1e39d[MainActivity]: stopped(false) old=false D/Capacitor/App: Firing change: true V/FA: Activity resumed, time: 240567953 V/Capacitor/App: Notifying listeners for event appStateChange D/Capacitor/App: No listeners found for event appStateChange I/System.out: (HTTPLog)-Static: isSBSettingEnabled false I/System.out: (HTTPLog)-Static: isSBSettingEnabled false D/Capacitor: App resumed D/ViewRootImpl@9f1e39d[MainActivity]: MSG_WINDOW_FOCUSCHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a1ce927[MainActivity] D/InputMethodManager: getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a1ce927[MainActivity] getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.marceloj.open7 ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus V/Capacitor/Network: Notifying listeners for event networkStatusChange D/Capacitor/Network: No listeners found for event networkStatusChange I/Capacitor/Console: File: http://localhost/default~pages-login-login-module~pages-login-step2-login-step2-module-es2015.js - Line 94 - Msg: Facebook access token is ${result.accessToken.token} I/Capacitor/Console: File: http://localhost/pages-login-login-module-es2015.js - Line 263 - Msg: Terminou o login.... D/ViewRootImpl@7e54b66[FacebookActivity]: stopped(true) old=false W/libEGL: EGLNativeWindowType 0x7a57fac110 disconnect failed D/ViewRootImpl@7e54b66[FacebookActivity]: dispatchDetachedFromWindow D/InputTransport: Input channel destroyed: '891ed56', fd=179 V/FA: Connecting to remote service V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 2 I/System.out: (HTTPLog)-Static: isSBSettingEnabled false I/System.out: (HTTPLog)-Static: isSBSettingEnabled false E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} I/System.out: (HTTPLog)-Static: isSBSettingEnabled false (HTTPLog)-Static: isSBSettingEnabled false V/FA: Inactivity, disconnecting from the service

BresciMa commented 3 years ago

I notice this error happens whenever the user has not "accepted" the Facebook App, in the confirmation window of the APP. When I come back in a new login, for users who have already accepted the app, the error message below does not happen. But I realized that despite the error, I am able to authenticate with the new version of the plugins.

What's happening?

E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} I/System.out: (HTTPLog)-Static: isSBSettingEnabled false (HTTPLog)-Static: isSBSettingEnabled false E/GraphResponse: {HttpStatus: 400, errorCode: 190, subErrorCode: 460, errorType: OAuthException, errorMessage: Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.} I/.marceloj.open: Compiler allocated 4266KB to compile void android.view.ViewRootImpl.performTraversals()

rdlabo commented 3 years ago

This is not @rdlabo/capacitor-facebook-login, and not support. And you used cordova-plugin-facebook4 . Perhaps these will conflict.

Please try demo. Plugins can also conflict with each other, so test in plain.

BresciMa commented 3 years ago

Hi Masahiko, I checked that this was wrong. In the version I am making available today, it is updated with the correct version of the plugins, and I removed the cordova-plugin-facebook4, according to the dependencies below.

In a developer test it worked, with the deployment through Android Studio. I will go up to the Play Store to see if it works ok for downloaded apps.

Arigatou 有難う

_"@angular/common": "~11.2.13",
"@angular/core": "~11.2.13",
"@angular/fire": "^6.1.4",
"@angular/forms": "~11.2.13",
"@angular/platform-browser": "~11.2.13",
"@angular/platform-browser-dynamic": "~11.2.13",
"@angular/router": "~11.2.13",
"@capacitor-community/facebook-login": "^2.0.0",
"@capacitor/android": "^2.4.3",
"@capacitor/core": "2.4.3",
"@ionic-native/core": "^5.32.1",
"@ionic-native/push": "^5.32.1",
"@ionic-native/splash-screen": "^5.32.1",
"@ionic-native/status-bar": "^5.32.1",
"@ionic/angular": "^5.6.6",
"async-mutex": "^0.2.6",
"es6-promise-plugin": "^4.2.2",
"firebase": "^8.1.1",
"globalthis": "^1.0.2",
"ionic-rating": "^2.0.0",
"phonegap-plugin-multidex": "^1.0.0",
"rxjs": "~6.5.5",
"tslib": "^2.2.0",
"zone.js": "~0.10.3"_
rdlabo commented 3 years ago

It seems to have been resolved, so close this issue.