updated the GitHub provider to ignore extra emails request errors in case of unsufficient custom scopes
This commit is contained in:
		
							parent
							
								
									9033cd109e
								
							
						
					
					
						commit
						0439af458f
					
				|  | @ -64,8 +64,8 @@ func (p *Github) FetchAuthUser(token *oauth2.Token) (*AuthUser, error) { | |||
| 		AccessToken: token.AccessToken, | ||||
| 	} | ||||
| 
 | ||||
| 	// in case user set "Keep my email address private",
 | ||||
| 	// email should be retrieved via extra API request
 | ||||
| 	// in case user has set "Keep my email address private", send an
 | ||||
| 	// **optional** API request to retrieve the verified primary email
 | ||||
| 	if user.Email == "" { | ||||
| 		client := p.Client(token) | ||||
| 
 | ||||
|  | @ -75,6 +75,12 @@ func (p *Github) FetchAuthUser(token *oauth2.Token) (*AuthUser, error) { | |||
| 		} | ||||
| 		defer response.Body.Close() | ||||
| 
 | ||||
| 		// ignore not found errors caused by unsufficient scope permissions
 | ||||
| 		// (the email field is optional, return the auth user without it)
 | ||||
| 		if response.StatusCode == 404 { | ||||
| 			return user, nil | ||||
| 		} | ||||
| 
 | ||||
| 		content, err := io.ReadAll(response.Body) | ||||
| 		if err != nil { | ||||
| 			return user, err | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue