The HybridAuth documentation as many have noted is extremely lacking, so I'm having a hard time finding the proper method for dealing with Expired Tokens during an attempted Auth sequence. My code is currently:
try {
$provider = /* Provider Object in our system */
// Initialize HybridAuth
$client = new Hybrid_Auth($provider->get_config());
// try to authenticate with the selected provider
$adapter = $client->authenticate( $provider->name );
// then grab the user profile
/* @var $user_profile Hybrid_User_Profile */
$user_profile = $adapter->getUserProfile();
} catch( Exception $e ) {
$user_profile = NULL;
$adapter->logout();
}
If the session is still active at our end for whatever reason, but the token has expired at the provider, the line $user_profile = $adapter->getUserProfile();
just prior to the catch
is throwing an exception which is expected (although the error messages are missing some very important info and are somewhat misleading).
I was able to find in another thread (which I'm sorry I can't find, please feel free to edit in a link if you know of an example) that I need to instruct HybridAuth to forget the token info by using the $adapter->logout();
method.
So what now? Am I supposed to redirect, if so, what address? What's the best practice here?
Any insights would be gratefully appreciated!