Problem/Motivation

Social Auth implementers are now storing tokens to allow external modules to access more data. However, they way to retrieve them from different social networks differs which makes it confusing.

For reference, follow #2857170: Remove access token session variables if login fails, #2857305: Save access token to allow external modules to request more data, and #2857106: Get the URL to user social page

Proposed resolution

Create interfaces for different authentication methods.

As an example, Google and Facebook implementers use OAuth 2, so we can create an interface which should be use in FacebookAuthManager and GoogleAuthManager.

Remaining tasks

  • Write interface for OAuth2
  • Determine more authentication methods which might need an interface

API changes

External methods will need to change the way they access data.

Example for OAuth2

/* @var \Google_Client $client */
$client = $this->networkManager->createInstance('social_auth_google')->getSdk();

$this->googleManager->setClient($client)
    ->setAccessToken($this->session->get('social_auth_google_access_token'))
    ->authenticate()

$user = $this->googleManager->getUserInfo();
CommentFileSizeAuthor
#6 Screen Shot 2017-03-07 at 2.33.17 PM.png108.02 KBParis2020

Comments

gvso created an issue. See original summary.

  • gvso committed 07d93c2 on 8.x-1.x
    Issue #2857682: Add interface and basic class for OAuth2
    
gvso’s picture

Issue summary: View changes

  • gvso committed 3e6f3ba on 8.x-1.x
    Issue #2857682: Change oAuthAuthenticate method to authenticate
    
Paris2020’s picture

I've installed the dev version module Social Auth on a new D8 site. I followed all the instructions from this documentation https://www.drupal.org/node/2764227.

Everything went well until I clicked the google plus icon. Clicking the icon leads me to the correct url /user/login/google as mentioned in the documentation except that it then results in an error: Fatal error: Class 'Drupal\social_auth\AuthManager\OAuth2Manager' not found in /var/www/onboarding_amazee_com_dev/public_html/web/modules/contrib/social_auth_google/src/GoogleAuthManager.php on line 12

Paris2020’s picture

StatusFileSize
new108.02 KB

What's weird is that when I look in the GoogleAuthManager.php file on line 5 Drupal\social_auth\AuthManager\OAuth2Manager is there (see 1st attached file)

gvso’s picture

Issue summary: View changes

According to the error Fatal error: Class 'Drupal\social_auth\AuthManager\OAuth2Manager' not found, it seems you didn't install the dev version of Social Auth. As stated in the documentation, Social Auth implementers dev branches are only guaranteed to work with the dev branch of Social API and Social Auth.

Hope that helped!

gvso’s picture

Issue summary: View changes
Paris2020’s picture

Thank you I actually just installed the dev version of social_auth_google and didn't actually install social_auth itself. Everything works as expected.

  • gvso committed 1a3af4a on 8.x-1.x
    Issue #2857682: Remove getUserInfo method from OAuth2ManagerInterface
    
MaskyS’s picture

Does this issue still need to be open? @gvso

gvso’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev

So far, implementers have only need OAuth2 integration. The exception is Twitter which is still using OAuth 1 (but they are currently moving to 2). However, we can not assure that future implementers won't be using Hawk or other authentication scheme.

gvso’s picture

Status: Active » Closed (outdated)

It seems like OAuth2 is the only protocol we have had to deal so far, I'm closing this issue. We might reopen it if needed