I would like to test the code path where a Facebook user's access token has expired and I need to renew the token. I noticed that the access token expires 2 months after it has been created. I don't want to wait 2 months to test that code path, so I would like a way to simulate this expiration. I am scared that my code will crash if I never test this situation for the following mysteries:
[FBSession openActiveSessionWithReadPermissions:permArray allowLoginUI:NO completionHandler:someFunction]
to silently reconnect a Facebook user that has already connected in the past. Notice how allowLoginUI is NO. Does it have to be YES to allow the user to re-login and renew the token or can the token be silently renewed?FBSessionStateOpen
and FBSessionStateOpenTokenExtended
. When the token becomes extended, does the state machine remain in the token extended state, or will it go to the extended state and then immediately go to the open state? I need to know the state transition, so I don't run my handlers twice.[FBSession activeSession].accessToken
become nil or does it remain as the old expired token?[FBSession activeSession].expirationDate
: is it nil, the old expiration date, or automatically becomes new expiration date?To make a token expired, the easiest way is to log into FB on your computer, go to App Center, click "My Apps", and remove your app by clicking the small X next to your app. This will cause the token to become "expired". Once this happens, you cannot automatically renew the token without interaction from the user. You must re-open the authentication UI and the user must click "Allow"
In regards to your questions:
allowLoginUI must be YES. If the token expires, the user must interact with the UI before you can get a new token and setting it to NO will have it fail silently.
I believe the TokenExtended state would only happen when extending a currently active token. If a user uses your app before the 2 month period is over, the FB SDK will automatically extend the token for your periodically. This is not the same as renewing an expired token though. Not 100% sure of this though, as I haven't tested this state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With