Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webchemistry/oauth-social
LinkedIn, Google oauth
https://github.com/webchemistry/oauth-social
Last synced: about 1 month ago
JSON representation
LinkedIn, Google oauth
- Host: GitHub
- URL: https://github.com/webchemistry/oauth-social
- Owner: WebChemistry
- Created: 2020-10-26T09:19:50.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-25T18:37:52.000Z (over 2 years ago)
- Last Synced: 2024-11-06T01:18:39.237Z (about 2 months ago)
- Language: PHP
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Usage
Nette extension:
```neon
extensions:
oAuthSocial: WebChemistry\OAuthSocial\DI\OAuthSocialExtensionoAuthSocial:
google:
id: 'clientId'
secret: 'clientSecret'
instances:
login: 'Module:Presenter:redirection'
linkedIn:
id: 'clientId'
secret: 'clientSecret'
instances:
login: 'Module:Presenter:redirection'
```Presenter
```php
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:');
}}
}
```