@@ -91,7 +91,9 @@ export async function exchangeAuthCodeForAccessToken(
9191 clientSecret : authOptions . clientSecret ,
9292 code : authCode ,
9393 request : request . defaults ( {
94- baseUrl : getGitHubAuthBaseUrl ( authOptions . hostname ) . toString ( ) ,
94+ baseUrl : getGitHubAuthBaseUrl ( authOptions . hostname )
95+ . toString ( )
96+ . replace ( / \/ $ / , '' ) ,
9597 } ) ,
9698 } ) ;
9799
@@ -114,7 +116,7 @@ export async function addAccount(
114116 token : encryptedToken ,
115117 } as Account ;
116118
117- newAccount = await refreshAccount ( newAccount ) ;
119+ newAccount = await refreshAccount ( newAccount , true ) ;
118120 const newAccountUUID = getAccountUUID ( newAccount ) ;
119121
120122 const accountAlreadyExists = accountList . some (
@@ -145,9 +147,16 @@ export function removeAccount(auth: AuthState, account: Account): AuthState {
145147 } ;
146148}
147149
148- export async function refreshAccount ( account : Account ) : Promise < Account > {
150+ export async function refreshAccount (
151+ account : Account ,
152+ skipClientCache = false ,
153+ ) : Promise < Account > {
149154 try {
150- const response = await fetchAuthenticatedUserDetails ( account ) ;
155+ const response = await fetchAuthenticatedUserDetails (
156+ account ,
157+ skipClientCache ,
158+ ) ;
159+
151160 const user = response . data ;
152161
153162 // Refresh user data
@@ -185,7 +194,7 @@ export async function refreshAccount(account: Account): Promise<Account> {
185194 } catch ( err ) {
186195 rendererLogError (
187196 'refreshAccount' ,
188- `failed to refresh account for user ${ account . user . login } ` ,
197+ `failed to refresh account for user ${ account . user ? .login ?? account . hostname } ` ,
189198 err ,
190199 ) ;
191200 }
0 commit comments