Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login failed with custom Oauth2 provider: Can not get identifier from provider #409

Closed
nl8590687 opened this issue Apr 25, 2023 · 1 comment

Comments

@nl8590687
Copy link

nl8590687 commented Apr 25, 2023

Hi,

I meet some trouble when using nextcloud-social-login
The function getUserProfile() in file sociallogin/lib/Provider/CustomOAuth2.php need to add userid to get user profile, otherwise will login failed with message "Can not get identifier from provider "

before

if (!isset($response->identifier)) {
            $response->identifier = $response->id
                ?? $response->ID
                ?? $response->data->id
                ?? $response->user_id
                ?? $response->userId
                ?? $response->oauth_user_id
                ?? $response->sub
                ?? null
            ;
        }

after:

  if (!isset($response->identifier)) {
              $response->identifier = $response->id
                  ?? $response->ID
                  ?? $response->data->id
                  ?? $response->user_id
                  ?? $response->userId
->                ?? $response->userid
                  ?? $response->oauth_user_id
                  ?? $response->sub
                  ?? null
              ;
          }

I use an inner oauth2 provider, whose userInfo struct defined as:

type UserInfoResponse struct {
	StatusCode    int    `json:"status_code" form:"status_code"`       // status code for response
	StatusMessage string `json:"status_message" form:"status_message"` // status message for response
	Userid        string `json:"userid" form:"userid"`                 // user ID
	Username      string `json:"username" form:"username"`             // username
	Avatar        string `json:"avatar" form:"avatar"`                 // avatar
	Email         string `json:"email" form:"email"`                   // email
	EmailVerified bool   `json:"email_verified" form:"email_verified"` // has email verified
	PhoneNumber   string `json:"phone_number" form:"phone_number"`     // phone number
	PhoneVerified bool   `json:"phone_verified" form:"phone_verified"` // has phone number verified
	CreateTime    int64  `form:"create_time"`                          // user created time
}
@zorn-v
Copy link
Owner

zorn-v commented Apr 26, 2023

Added in v5.4.3

@zorn-v zorn-v closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants