I see the following error notice after signing in using Paypal. No scopes/api calls were added.
https://gist.github.com/MaskyS/42a05b51527d8cbc847b91238a35ca8b

Comments

Kifah Meeran created an issue. See original summary.

MaskyS’s picture

Status: Active » Needs review
StatusFileSize
new1.78 KB

The problem is due to two factors:

- Paypal does not send back user's email and name if those specific scopes were not requested.
- Despite the actual code adding email profile scopes as default scopes to the $scopes variable, they were not being requested unless additional scopes were added by site manager in the settings form. The culprit code:

    if ($this->getScopes()) {
      $options = [
        'scope' => $scopes,
      ];
      $login_url = $this->client->getAuthorizationUrl($options);
    }
    else {
      $login_url = $this->client->getAuthorizationUrl();
    }

Attached below is a patch that fixes this issue.

gvso’s picture

Title: Error notice after signing in using Paypal » Refactor PaypalAuthManager
Status: Needs review » Needs work

That file needs a lot of refactoring actually. What about doing that here and including these changes?

gvso’s picture

Status: Needs work » Needs review
StatusFileSize
new8.25 KB

Can you please test this patch?

gvso’s picture

StatusFileSize
new8 KB
new641 bytes
gvso’s picture

Status: Needs review » Needs work
+++ b/src/PaypalAuthManager.php
@@ -15,95 +11,45 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+   * The Social Auth Amazon settings.

Should be PayPal. Please change it before committing

MaskyS’s picture

The latest patch is not working and is returning an WSOD. I tried clearing the cache, and even uninstalling and re-installing the module. No luck. https://pastebin.com/7N2BwUPD

MaskyS’s picture

Does this maybe need further changes due to http://cgit.drupalcode.org/social_auth_paypal/commit/?id=c60028e ?

gvso’s picture

Status: Needs work » Needs review
StatusFileSize
new8.46 KB
new700 bytes

Sorry. I forgot to update the service declaration.

MaskyS’s picture

Status: Needs review » Needs work

The website encountered an unexpected error. Please try again later.
Error: Call to a member function get() on null in Drupal\social_auth_paypal\PaypalAuthManager->getScopes() (line 129 of modules/social_auth_paypal/src/PaypalAuthManager.php).

Drupal\social_auth_paypal\PaypalAuthManager->getScopes() (Line: 94)
Drupal\social_auth_paypal\PaypalAuthManager->getPaypalLoginUrl() (Line: 119)
Drupal\social_auth_paypal\Controller\PaypalAuthController->redirectToPaypal()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 184)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

gvso’s picture

Status: Needs work » Needs review
StatusFileSize
new8.55 KB
new789 bytes
gvso’s picture

Status: Needs review » Needs work

I noticed that there are other changes that should be done to the file

MaskyS’s picture

I tried appyling the patch in #8 then making the changes in #11, got the following https://pastebin.com/qPu4wPDX error. I guess you were referring to changes that were not included in previous patches?

gvso’s picture

I wasn't actually referring to that, but to changes that were introduced to Social Auth Instagram at #2938389: Refactor InstagramAuthManager.

Also, I don't think I'm the most appropriate person to fix this issue since I can't test the changes. Maybe you can work on this, and I can help you and review the code.

MaskyS’s picture

Assigned: Unassigned » MaskyS

gotcha. I'll submit a patch soon. Hopefully before the weekend :)