webchemistry / oauth-social
Installs: 2 805
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- league/oauth2-facebook: ^2.0
- league/oauth2-google: ^3.0
- league/oauth2-linkedin: ^5.1
- nette/http: ^3.0
- webchemistry/oauth2-seznam: ^1.0
Requires (Dev)
- nette/di: ^3.0
README
Nette extension:
extensions: oAuthSocial: WebChemistry\OAuthSocial\DI\OAuthSocialExtension oAuthSocial: google: id: 'clientId' secret: 'clientSecret' instances: login: 'Module:Presenter:redirection' linkedIn: id: 'clientId' secret: 'clientSecret' instances: login: 'Module:Presenter:redirection'
Presenter
class Presenter { /** @var GoogleOAuthAccessor @inject */ public GoogleOAuthAccessor $googleOAuthAccessor; public function actionLogin(?string $backlink): void { $this->redirectUrl($this->googleOAuthAccessor->get('login')->getAuthorizationUrl([ 'backlink' => $backlink, ])); } public function actionRedirection(): void { try { $identity = $this->googleOAuthAccessor->get('login')->getIdentityAndVerify(); } catch (OAuthSocialException $exception) { $this->flashMessage($exception->getMessage(), 'error'); $this->redirect('Homepage:'); } catch (Throwable $exception) { $this->flashMessage('Something gone wrong.', 'error'); $this->redirect('Homepage:'); } } }