# Start IdP Sign-In

`POST /gate/idp/{provider}/authorize` · Identity & Access · Federation

Starts a redirect sign-in for an end user of this project. The page sends the origin-allowlisted `redirectUri` and `codeChallenge`, the base64url S256 of a verifier it keeps, with `codeChallengeMethod` `S256`; the response gives the identity provider's URL to send the browser to. `plain` is refused. A customer page may call this cross-origin when its origin is in `allowed_redirect_uris` of one of the project's enabled providers.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `provider` | path | yes | The identity provider to sign in with, as configured on the project: `google`, `github`, `microsoft`, `oidc` or `saml`. Example: `"google"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `redirectUri` | string | yes | Where the end user lands after signing in with the provider. Its origin must be on the provider configuration's `allowedRedirectUris`, or it must exactly equal one of its `nativeRedirectUris`; otherwise 403 `K9O_IDP_REDIRECT_URI_NOT_ALLOWED`. The platform redirects there with `#code=...` in the fragment (or `#error=...&error_description=...`). |
| `codeChallenge` | string | no | Required. The PKCE challenge for a verifier your app keeps: base64url(SHA-256(verifier)), exactly 43 characters. Send the verifier with the code to `POST /@{projectSlug}/gate/idp/exchange`. Missing or malformed gets 400 `K9O_INVALID_FIELD_VALUE`. |
| `codeChallengeMethod` | string | no | Required, and must be `S256`. `plain` is refused with 400 `K9O_INVALID_FIELD_VALUE`. |

```json
{
  "redirectUri": "string"
}
```

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | Where to send the end user to sign in. |
| `data.authorizationUrl` | string | yes | The provider's sign-in page URL, with this sign-in's sealed `state` in it. Send the browser there with a full-page navigation. For `saml` it is the IdP's SSO URL with a SAML request. The state expires after 10 minutes. After sign-in the provider returns to the platform's callback, which redirects (302) to `redirectUri` with a single-use code in the fragment that expires after 60 seconds. |
| `meta` | object | yes | Always an empty object on this route. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 400 | `K9O_INVALID_FIELD_VALUE` | `codeChallenge` is missing or malformed, or `codeChallengeMethod` isn't `S256` (reason `code_challenge_required`). |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/gate/idp/google/authorize' \
  -H 'Content-Type: application/json' \
  -d '{
  "redirectUri": "string"
}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/gate/idp/google/authorize', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "redirectUri": "string"
}),
});
const { data, meta } = await res.json();
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.gate.signInWithProvider('google', {
  redirectUri: 'string'
})
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.gate.sign_in_with_provider("google", {
    "redirectUri": "string"
})
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Gate.SignInWithProvider(ctx, "google", map[string]any{"redirectUri": "string"})
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.gate.sign_in_with_provider("google", json!({"redirectUri": "string"})).await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.gate().signInWithProvider("google", Map.of("redirectUri", "string"))
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Gate.SignInWithProviderAsync("google", new Dictionary<string, object> { ["redirectUri"] = "string" })
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.gate.sign_in_with_provider("google", { redirectUri: "string" })
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->gate->sign_in_with_provider('google', ['redirectUri' => 'string'])
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.gate.signInWithProvider("google", {
  redirectUri: "string"
})
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.gate.signInWithProvider("google", {
  redirectUri: "string"
})
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.gate.signInWithProvider('google', {
  redirectUri: 'string'
})
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.gate.signInWithProvider('google', {
  redirectUri: 'string'
})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/identity-access/start-idp-sign-in
