Нотатка. sociallogin of nextcloud use authentication via oauth2 from mastodon
Нотатка.
Задача - авторизуватися в nextcloud з використанням бази даних користувачівmastodon.
####
mastodon
Server mastodon - https://mastodon.lexxai.pp.ua
New Applications - https://mastodon.lexxai.pp.ua/settings/applications/new
Name: nextcloud
Application website: https://cloud.lexxai.pp.ua
Redirect URI: https://cloud.lexxai.pp.ua/apps/sociallogin/custom_oauth2/mastodon
Scopes: read:accounts

mastodon - new application oauth2

mastodon - application key/secret
Client key 28q0bbVKEH44wzU0RCsHwypz9b3P48ONPcnCh2rpOnA
Client secret 3Nehr1vv_tmhQBxLPeN05NWRyHQ-YuZGqxYmzeTwi30
Nextcloud
Server Nextcloud - https://cloud.lexxai.pp.ua
Administration - Social Login https://cloud.lexxai.pp.ua/settings/admin/sociallogin
Custom OAuth2 +
Internal name: mastodon
Title: mastodon
API Base URL: http://mastodon.lexxai.pp.ua
Authorize url (can be relative to base URL): https://mastodon.lexxai.pp.ua/oauth/authorize
Token url (can be relative to base URL): https://mastodon.lexxai.pp.ua/oauth/token
Profile url (can be relative to base URL): https://mastodon.lexxai.pp.ua/api/v1/accounts/verify_credentials
Logout URL (optional): https://cloud.lexxai.pp.ua/login?redirect_url=/apps/dashboard/
Client Id: 28q0bbVKEH44wzU0RCsHwypz9b3P48ONPcnCh2rpOnA
Client Secret: 3Nehr1vv_tmhQBxLPeN05NWRyHQ-YuZGqxYmzeTwi30
Scope: read:accounts
Default group: users
NextCloud Custom OAuth2

update user profile every login
Nextcloud with Log In with mastodon
Add username to netxcloud from mastodon:
nextcloud/apps/sociallogin/lib/Provider/CustomOAuth2.php
…
$userProfile = new User\Profile();
$dataArray=$data->toArray();
$userProfile->displayName = $dataArray[‘username’];
…