# Social login

OAuth is commonly used for logging in to a social media account from a third-party app. It is a secure and convenient way to authenticate users and share information between applications.

## Provider token

You can use the provider token and provider refresh token returned to make API calls to the OAuth provider. For example, you can use the Google provider token to access Google APIs on behalf of your user.

## Supported providers

* [Google](/docs/configuration/social-login/auth-google)
* [Apple](/docs/configuration/social-login/auth-apple)
* [Facebook](/docs/configuration/social-login/auth-facebook)
* [X](/docs/configuration/social-login/auth-twitter)
* [Discord](/docs/configuration/social-login/auth-discord)
* [Line](/docs/configuration/social-login/auth-line)

## Add social login to your app

Social login works the same way across every Openfort client SDK: call `initOAuth` with the provider and hand the user off to the OAuth flow. Pick your SDK:

:::code-group

```tsx [React]
import { OAuthProvider, useOAuth } from '@openfort/react'

const { initOAuth } = useOAuth()

const loginWithGoogle = () => initOAuth({ provider: OAuthProvider.GOOGLE })
```

```tsx [React Native]
import { OAuthProvider, useOAuth } from '@openfort/react-native'

const { initOAuth } = useOAuth()

const loginWithGoogle = () => initOAuth({ provider: OAuthProvider.GOOGLE })
```

```ts [JavaScript]
import { OAuthProvider } from '@openfort/openfort-js'

const url = await openfort.auth.initOAuth({
  provider: OAuthProvider.GOOGLE,
  redirectTo: 'https://your-app.com/auth/callback',
})
window.location.href = url
```

```swift [Swift]
import OpenfortSwift

let result = try await OFSDK.shared.initOAuth(
  params: OFInitOAuthParams(
    provider: OFOAuthProvider.google.rawValue,
    options: ["redirectTo": AnyCodable("myapp://login")]
  )
)
```

:::

Swap `GOOGLE` for any [supported provider](#supported-providers). For the full API (linking providers, handling the callback, polling for completion), see your SDK's guide:

* [React `useOAuth`](/docs/products/embedded-wallet/react/hooks/useOAuth)
* [React Native `useOAuth`](/docs/products/embedded-wallet/react-native/hooks/useOAuth)
* [JavaScript `auth.initOAuth`](/docs/products/embedded-wallet/javascript/auth/oauth-login)
* [Swift `initOAuth`](/docs/products/embedded-wallet/swift/auth/oauth)

## Troubleshooting

### Invalid CallbackURL error

If you receive an `Invalid CallbackURL` error when initiating OAuth, verify that:

* The OAuth provider has been configured in the [Openfort dashboard](https://dashboard.openfort.io/providers).
* The `redirectTo` URL passed to `initOAuth()` matches a valid URL for your application.
