From 5659b5e9eb5fd0b843bbf8ad1b22c805efe3eb43 Mon Sep 17 00:00:00 2001 From: Elliot Sawyer Date: Wed, 20 Jul 2022 14:16:54 +1200 Subject: [PATCH] Check for sub if user_id is not present Fixes https://github.com/RiskioFr/oauth2-auth0/issues/24 --- src/Auth0ResourceOwner.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Auth0ResourceOwner.php b/src/Auth0ResourceOwner.php index 142f3a5..517f23c 100644 --- a/src/Auth0ResourceOwner.php +++ b/src/Auth0ResourceOwner.php @@ -23,7 +23,12 @@ public function __construct(array $response = []) */ public function getId() { - return $this->getValueByKey($this->response, 'user_id'); + $id = $this->getValueByKey($this->response, 'user_id'); + if(!$id) { + $id = $this->getValueByKey($this->response, 'sub'); + } + + return $id; } /**