refreshUserInfo
Refresh the current user's profile data from a connected provider, from the client.
The refreshUserInfo client method refreshes the current user's profile data from a connected provider, without requiring re-authentication, from a client-side or browser context.
import { authClient } from "@/lib/auth-client"
const userInfo = await authClient.refreshUserInfo("github")Reference
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| providerId | string | Yes | The id of the OAuth provider to refresh user info from. |
Returns
| Return Type | Description |
| ----------------------------- | ----------- | ------------------------------------------------------------------------------------ |
| Promise<Session<DefaultUser> | null> | Resolves to the refreshed session object on success or null when refreshing fails. |
Behavior
- Cookies are read automatically from the browser context — you don't need to handle them or CSRF tokens manually.
- Uses the provider's existing access token to fetch fresh profile data and normalizes it into the session's
Userobject, matchingapi.refreshUserInfo's behavior. - If the refresh fails (invalid or expired access token, or the provider request fails), the function returns
null. On success it returns the refreshed session object.
Usage
Refresh user info
import { authClient } from "@/lib/auth-client"
const userInfo = await authClient.refreshUserInfo("github")
console.log("refreshed session:", session)Handling failure
import { authClient } from "@/lib/auth-client"
const userInfo = await authClient.refreshUserInfo("github")
if (!userInfo) {
window.location.assign("/login")
}
console.log("refreshed session:", session)