Skip to content

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

@nl8590687

Description

@nl8590687

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions