> ## Documentation Index
> Fetch the complete documentation index at: https://docs.discord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Public Client Integration

> Create provisional accounts directly from the client when you don't have a backend server.

export const SlashBoxIcon = props => <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="currentColor" fill-rule="evenodd" d="M5 2a3 3 0 0 0-3 3v14a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V5a3 3 0 0 0-3-3H5Zm12.79 3.37a.25.25 0 0 0-.22-.37h-3.13a.75.75 0 0 0-.66.38L6.21 18.63c-.1.16.03.37.22.37h3.13c.27 0 .52-.14.66-.38l7.57-13.25Z" clip-rule="evenodd" /></svg>;

export const LinkIcon = props => <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="currentColor" d="M16.32 14.72a1 1 0 0 1 0-1.41l2.51-2.51a3.98 3.98 0 0 0-5.62-5.63l-2.52 2.51a1 1 0 0 1-1.41-1.41l2.52-2.52a5.98 5.98 0 0 1 8.45 8.46l-2.52 2.51a1 1 0 0 1-1.41 0ZM7.68 9.29a1 1 0 0 1 0 1.41l-2.52 2.51a3.98 3.98 0 1 0 5.63 5.63l2.51-2.52a1 1 0 0 1 1.42 1.42l-2.52 2.51a5.98 5.98 0 0 1-8.45-8.45l2.51-2.51a1 1 0 0 1 1.42 0Z" /><path fill="currentColor" d="M14.7 10.7a1 1 0 0 0-1.4-1.4l-4 4a1 1 0 1 0 1.4 1.4l4-4Z" /></svg>;

export const WrenchIcon = props => <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="currentColor" d="M7.8 15.77c.7.43 1.2 1.14 1.2 1.96V21a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-3.27c0-.82.5-1.53 1.2-1.96a8.06 8.06 0 0 0 .12-13.63c-.6-.39-1.32.09-1.32.8v5.98a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V2.94c0-.71-.72-1.19-1.32-.8a8.06 8.06 0 0 0 .12 13.63Z" /></svg>;

## Authentication for Public Clients

<Warning>
  This method requires enabling **Public Client** for your app. Most games will not want to ship with this enabled. [Learn more](/developers/discord-social-sdk/core-concepts/oauth2-scopes#oauth2-client-types)
</Warning>

<Warning>
  Use Public Client Integration only if you don't have a server-authoritative backend and therefore require a Public Client for authentication.
</Warning>

If you have `Public Client` enabled on your Discord app, you can use the following code to authenticate your players with the external provider directly from the client — no backend required. Before using this method, you must [configure your identity provider](/developers/discord-social-sdk/development-guides/provisional-accounts/identity-providers) in the Developer Portal.

```cpp theme={"system"}
// filepath: your_game/auth_manager.cpp
void AuthenticateUser(std::shared_ptr<discordpp::Client> client) {
    // Get your external auth token (Steam, OIDC, etc.)
    std::string externalToken = GetExternalAuthToken();

    // Get provisional token from Discord
    client->GetProvisionalToken(DISCORD_APPLICATION_ID,
        discordpp::AuthenticationExternalAuthType::OIDC,
        externalToken,
        [client](discordpp::ClientResult result, std::string accessToken, std::string refreshToken, discordpp::AuthorizationTokenType tokenType, int32_t expiresIn, std::string scope) {
        if (result.Successful()) {
            std::cout << "🔓 Provisional token received! Establishing connection...\n";
            client->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [client](discordpp::ClientResult result) {
                client->Connect();
            });
        } else {
            std::cerr << "❌ Provisional token request failed: " << result.Error() << std::endl;
        }
    });
}
```

### How the Flow Works

```mermaid theme={"system"}
sequenceDiagram
    autonumber
    actor P as Player
    participant Prov as External Provider<br/>(OIDC, Steam, EOS)
    participant C as Game Client (SDK)
    participant D as Discord

    P->>Prov: Authenticate
    Prov-->>C: External auth token
    C->>D: GetProvisionalToken(app_id, auth_type, external_token)
    alt No account / provisional account exists
        D-->>C: Access token
        C->>D: UpdateToken() → Connect()
    else Full Discord account exists
        D-->>C: Error (use OAuth2 flow)
    end
```

Once authentication is complete, you can use the access token as you would a full Discord user's access token. See [Managing Provisional Accounts](/developers/discord-social-sdk/development-guides/provisional-accounts/managing-accounts) for token refresh, storage, and display names.

## Error Handling

Common error codes and solutions when creating a provisional account:

| Code   | Meaning                      | Solution                                                                    |
| ------ | ---------------------------- | --------------------------------------------------------------------------- |
| 530000 | Application not configured   | Contact Discord support to enable provisional accounts for your application |
| 530001 | Expired ID token             | Request a new token from your identity provider                             |
| 530004 | Token too old                | Request a new token (tokens over 1 week old are rejected)                   |
| 530006 | Username generation failed   | Retry the operation (temporary error)                                       |
| 530007 | Invalid client secret        | Verify or regenerate your client secret in the Developer Portal             |
| 530010 | User account non-provisional | User already linked to Discord account - use standard OAuth2 flow           |

If you are using OIDC, you may encounter more specific errors:

| Code   | Meaning                      | Solution                                                                                                               |
| ------ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| 530002 | Invalid issuer               | Verify the `iss` claim in your ID token exactly matches the issuer URL in your OIDC configuration                      |
| 530003 | Invalid audience             | Verify the `aud` claim in your ID token includes the client ID in your OIDC configuration                              |
| 530008 | OIDC configuration not found | Verify your issuer URL is correct, accessible over HTTPS, and serves a valid discovery document without HTTP redirects |
| 530009 | OIDC JWKS not found          | Verify your JWKS endpoint is accessible over HTTPS without HTTP redirects                                              |
| 530020 | Invalid OIDC JWT token       | Verify your ID token is properly signed and uses a supported algorithm                                                 |
| 530027 | Missing `kid` header         | Ensure your ID token includes a `kid` (Key ID) header in the JWT header identifying the signing key                    |

***

## Next Steps

<CardGroup cols={3}>
  <Card title="Managing Provisional Accounts" href="/developers/discord-social-sdk/development-guides/provisional-accounts/managing-accounts" icon={<WrenchIcon />}>
    Refresh access tokens and set display names.
  </Card>

  <Card title="Merging Accounts" href="/developers/discord-social-sdk/development-guides/provisional-accounts/merging-accounts" icon={<LinkIcon />}>
    Merge a provisional account into a full Discord account.
  </Card>

  <Card title="Unmerging Accounts" href="/developers/discord-social-sdk/development-guides/provisional-accounts/unmerging-accounts" icon={<SlashBoxIcon />}>
    Sever the link between a Discord account and a provisional account.
  </Card>
</CardGroup>

Need help? Join the [Discord Developers Server](https://discord.gg/discord-developers) and share questions in the `#social-sdk-dev-help` channel for support from the community.

If you encounter a bug while working with the Social SDK, please report it here:  [https://dis.gd/social-sdk-bug-report](https://dis.gd/social-sdk-bug-report)

***

## Change Log

| Date           | Changes                                                   |
| -------------- | --------------------------------------------------------- |
| July 14, 2026  | Split the provisional accounts guide into its own section |
| March 17, 2025 | Initial release                                           |
