Create OAuth login config
Create an OAuth login configuration for a specific provider. With
type: personal (the default) this is the classic social-login
config, at most one per provider. With type: enterprise it creates a
new OIDC SSO connection (returning a generated connection_id) and
requires the enterprise block.
curl --request POST \
--url https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "123456789.apps.googleusercontent.com",
"client_secret": "GOCSPX-abc123def456",
"type": "enterprise",
"enabled": true,
"scopes": [
"openid"
],
"granted_scopes": [
"prld:pwd:write"
],
"options": {
"use_email_as_identifier": true,
"allow_email_account_merge": false,
"verify_email": false
},
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----"
},
"okta": {
"issuer_url": "https://dev-123456.okta.com/oauth2/default"
}
}
'import requests
url = "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}"
payload = {
"client_id": "123456789.apps.googleusercontent.com",
"client_secret": "GOCSPX-abc123def456",
"type": "enterprise",
"enabled": True,
"scopes": ["openid"],
"granted_scopes": ["prld:pwd:write"],
"options": {
"use_email_as_identifier": True,
"allow_email_account_merge": False,
"verify_email": False
},
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----
MIGT...base64...==
-----END PRIVATE KEY-----"
},
"okta": { "issuer_url": "https://dev-123456.okta.com/oauth2/default" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: '123456789.apps.googleusercontent.com',
client_secret: 'GOCSPX-abc123def456',
type: 'enterprise',
enabled: true,
scopes: ['openid'],
granted_scopes: ['prld:pwd:write'],
options: {
use_email_as_identifier: true,
allow_email_account_merge: false,
verify_email: false
},
apple: {
team_id: 'ABCDEF1234',
key_id: 'KEY123456',
p8_key: '-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----'
},
okta: {issuer_url: 'https://dev-123456.okta.com/oauth2/default'}
})
};
fetch('https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '123456789.apps.googleusercontent.com',
'client_secret' => 'GOCSPX-abc123def456',
'type' => 'enterprise',
'enabled' => true,
'scopes' => [
'openid'
],
'granted_scopes' => [
'prld:pwd:write'
],
'options' => [
'use_email_as_identifier' => true,
'allow_email_account_merge' => false,
'verify_email' => false
],
'apple' => [
'team_id' => 'ABCDEF1234',
'key_id' => 'KEY123456',
'p8_key' => '-----BEGIN PRIVATE KEY-----
MIGT...base64...==
-----END PRIVATE KEY-----'
],
'okta' => [
'issuer_url' => 'https://dev-123456.okta.com/oauth2/default'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}"
payload := strings.NewReader("{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}"
response = http.request(request)
puts response.read_body{
"config": {
"provider_id": "google",
"type": "enterprise",
"client_id": "123456789.apps.googleusercontent.com",
"enabled": true,
"scopes": [
"openid"
],
"options": {
"use_email_as_identifier": true,
"allow_email_account_merge": false,
"verify_email": false
},
"created_at": "2025-03-15T10:30:00Z",
"updated_at": "2025-03-15T12:00:00Z",
"connection_id": "ocon_01jqebhswje1ka1z7ahr9rfsgt",
"granted_scopes": [
"prld:pwd:write"
],
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----"
},
"okta": {
"issuer_url": "https://dev-123456.okta.com/oauth2/default"
},
"enterprise": {
"issuer_url": "https://acme.okta.com/oauth2/default",
"email_domain_allowlist": [
"acme.com"
],
"jit_provisioning": true,
"allow_email_account_merge": true,
"enforce_login": false,
"sync_profile_on_login": true,
"default_redirect_uri": "https://acme.yourapp.com/callback",
"claim_mapping": {
"email": "email",
"given_name": "given_name",
"family_name": "family_name",
"custom": {}
}
}
}
}{
"code": "invalid_request",
"status": "bad_request",
"message": "The request body is invalid."
}{
"code": "app_not_found",
"status": "not_found",
"message": "The application was not found."
}{
"code": "oauth_provider_already_configured",
"status": "conflict",
"message": "An OAuth configuration already exists for this provider."
}Authorizations
Path Parameters
Body
personal is the classic social-login config (at most one per
provider, addressed as …/oauth/{provider}). enterprise is a
per-connection OIDC SSO config (any number per provider, addressed as
…/oauth/{provider}/{connectionID}). Defaults to personal.
personal, enterprise "enterprise"
Prelude session scopes attached to the session when a login completes through this social provider (for example prld:pwd:write). Distinct from scopes, which are requested from the IdP. Each scope must first be in the app's allowed scopes, otherwise the request fails with scope_not_allowed.
["prld:pwd:write"]
curl --request POST \
--url https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "123456789.apps.googleusercontent.com",
"client_secret": "GOCSPX-abc123def456",
"type": "enterprise",
"enabled": true,
"scopes": [
"openid"
],
"granted_scopes": [
"prld:pwd:write"
],
"options": {
"use_email_as_identifier": true,
"allow_email_account_merge": false,
"verify_email": false
},
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----"
},
"okta": {
"issuer_url": "https://dev-123456.okta.com/oauth2/default"
}
}
'import requests
url = "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}"
payload = {
"client_id": "123456789.apps.googleusercontent.com",
"client_secret": "GOCSPX-abc123def456",
"type": "enterprise",
"enabled": True,
"scopes": ["openid"],
"granted_scopes": ["prld:pwd:write"],
"options": {
"use_email_as_identifier": True,
"allow_email_account_merge": False,
"verify_email": False
},
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----
MIGT...base64...==
-----END PRIVATE KEY-----"
},
"okta": { "issuer_url": "https://dev-123456.okta.com/oauth2/default" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: '123456789.apps.googleusercontent.com',
client_secret: 'GOCSPX-abc123def456',
type: 'enterprise',
enabled: true,
scopes: ['openid'],
granted_scopes: ['prld:pwd:write'],
options: {
use_email_as_identifier: true,
allow_email_account_merge: false,
verify_email: false
},
apple: {
team_id: 'ABCDEF1234',
key_id: 'KEY123456',
p8_key: '-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----'
},
okta: {issuer_url: 'https://dev-123456.okta.com/oauth2/default'}
})
};
fetch('https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'client_id' => '123456789.apps.googleusercontent.com',
'client_secret' => 'GOCSPX-abc123def456',
'type' => 'enterprise',
'enabled' => true,
'scopes' => [
'openid'
],
'granted_scopes' => [
'prld:pwd:write'
],
'options' => [
'use_email_as_identifier' => true,
'allow_email_account_merge' => false,
'verify_email' => false
],
'apple' => [
'team_id' => 'ABCDEF1234',
'key_id' => 'KEY123456',
'p8_key' => '-----BEGIN PRIVATE KEY-----
MIGT...base64...==
-----END PRIVATE KEY-----'
],
'okta' => [
'issuer_url' => 'https://dev-123456.okta.com/oauth2/default'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}"
payload := strings.NewReader("{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prelude.dev/v2/session/apps/{appID}/config/login/oauth/{provider}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"123456789.apps.googleusercontent.com\",\n \"client_secret\": \"GOCSPX-abc123def456\",\n \"type\": \"enterprise\",\n \"enabled\": true,\n \"scopes\": [\n \"openid\"\n ],\n \"granted_scopes\": [\n \"prld:pwd:write\"\n ],\n \"options\": {\n \"use_email_as_identifier\": true,\n \"allow_email_account_merge\": false,\n \"verify_email\": false\n },\n \"apple\": {\n \"team_id\": \"ABCDEF1234\",\n \"key_id\": \"KEY123456\",\n \"p8_key\": \"-----BEGIN PRIVATE KEY-----\\nMIGT...base64...==\\n-----END PRIVATE KEY-----\"\n },\n \"okta\": {\n \"issuer_url\": \"https://dev-123456.okta.com/oauth2/default\"\n }\n}"
response = http.request(request)
puts response.read_body{
"config": {
"provider_id": "google",
"type": "enterprise",
"client_id": "123456789.apps.googleusercontent.com",
"enabled": true,
"scopes": [
"openid"
],
"options": {
"use_email_as_identifier": true,
"allow_email_account_merge": false,
"verify_email": false
},
"created_at": "2025-03-15T10:30:00Z",
"updated_at": "2025-03-15T12:00:00Z",
"connection_id": "ocon_01jqebhswje1ka1z7ahr9rfsgt",
"granted_scopes": [
"prld:pwd:write"
],
"apple": {
"team_id": "ABCDEF1234",
"key_id": "KEY123456",
"p8_key": "-----BEGIN PRIVATE KEY-----\nMIGT...base64...==\n-----END PRIVATE KEY-----"
},
"okta": {
"issuer_url": "https://dev-123456.okta.com/oauth2/default"
},
"enterprise": {
"issuer_url": "https://acme.okta.com/oauth2/default",
"email_domain_allowlist": [
"acme.com"
],
"jit_provisioning": true,
"allow_email_account_merge": true,
"enforce_login": false,
"sync_profile_on_login": true,
"default_redirect_uri": "https://acme.yourapp.com/callback",
"claim_mapping": {
"email": "email",
"given_name": "given_name",
"family_name": "family_name",
"custom": {}
}
}
}
}{
"code": "invalid_request",
"status": "bad_request",
"message": "The request body is invalid."
}{
"code": "app_not_found",
"status": "not_found",
"message": "The application was not found."
}{
"code": "oauth_provider_already_configured",
"status": "conflict",
"message": "An OAuth configuration already exists for this provider."
}