Closed
Description
Repro Code
var sdk = new ClerkBackendApi(bearerAuth: "sk_test_...");
var request = new CreateSessionRequestBody
{
UserId = "user_...",
};
var response = await sdk.Sessions.CreateSessionAsync(request);
response.Session.Should().NotBeNull();
var sessionId = response!.Session!.Id;
sessionId.Should().NotBeNullOrEmpty();
var response2 = await sdk.Sessions.CreateSessionTokenAsync(sessionId); // Throws 415
SDKError.Response
{StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Wed, 29 Jan 2025 16:32:46 GMT
Connection: keep-alive
CF-Ray: 909a9ec3adac69d9-DFW
CF-Cache-Status: DYNAMIC
clerk-api-version: 2021-02-05
X-CFWorker: 1
x-clerk-trace-id: 9897512248aa9bf77c337efd2bb57efb
x-cloud-trace-context: 9897512248aa9bf77c337efd2bb57efb
Server: cloudflare
Content-Type: application/json
Content-Length: 228
}}
Speculation
Note that Sessions.CreateSessionTokenAsync has an optional second parameter for overriding the default expiration.
If we make the request as so, then the request succeeds:
var response2 = await sdk.Sessions.CreateSessionTokenAsync(sessionId, new());
As sessionId
is part of the request URL and the second argument is used for the request Body, it seems that the missing request body causes the problem.
Metadata
Metadata
Assignees
Labels
No labels