Skip to main content
Docs

User management

Use User methods to manage the current user's account. You can access the current user with clerk.user.

Reload user

let refreshedUser = try await user.reload()
let updatedUser = try await user.update(.init(
  username: "janedoe",
  firstName: "Jane",
  lastName: "Doe"
))
let emailAddress = try await user.createEmailAddress("jane@example.com")
let phoneNumber = try await user.createPhoneNumber("+15551234567")

Create external account with OAuth

Create an external account with an OAuth provider (e.g., Google, GitHub, see all providers):

let account = try await user.createExternalAccount(
  provider: .google,
  redirectUrl: "myapp://callback",
  additionalScopes: ["email", "profile"]
)
let account = try await user.createExternalAccount(
  provider: .apple,
  idToken: idToken
)
let account = try await user.connectAppleAccount()
let passkey = try await user.createPasskey()
let totp = try await user.createTOTP()
let verifiedTotp = try await user.verifyTOTP(code: "123456")
let deletedTotp = try await user.disableTOTP()
let backupCodes = try await user.createBackupCodes()
let invitations = try await user.getOrganizationInvitations()
let memberships = try await user.getOrganizationMemberships()
let suggestions = try await user.getOrganizationSuggestions()
let sessions = try await user.getSessions()
let updatedUser = try await user.updatePassword(
  .init(
    currentPassword: "old-password",
    newPassword: "new-password",
    signOutOfOtherSessions: true
  )
)
let imageResource = try await user.setProfileImage(imageData: imageData)
let deletedProfileImage = try await user.deleteProfileImage()
let deletedUser = try await user.delete()

Feedback

What did you think of this content?

Last updated on

GitHubEdit on GitHub