bland-finland-95044
01/09/2025, 8:43 PMbrief-egg-61061
01/09/2025, 8:44 PMbrief-egg-61061
01/09/2025, 8:44 PMbland-finland-95044
01/10/2025, 7:37 PMbrief-egg-61061
01/10/2025, 7:38 PMbrief-egg-61061
01/10/2025, 7:38 PMGET <https://api.console.ory.sh/projects/{project_id}/organizations>
Here are a few points to consider: 1. Endpoint: Make sure you're using the correct base URL. Instead of $mycustomdomain
, you should be using <https://api.console.ory.sh>
. 2. Project ID: Ensure that $myprojectid
is correctly replaced with your actual project ID. 3. Authentication: This endpoint requires authentication. Make sure you're including a valid authorization header with your request. As per the documentation, you should use a workspace API key: -H "Authorization: Bearer $WORKSPACE_API_KEY"
4. Permissions: Ensure that you have the necessary permissions to access this endpoint. A 403 Forbidden error in the response would indicate a permissions issue. 5. API Availability: Organizations are only available in Ory Network and are not supported in self-hosted Ory Kratos. Make sure you're using Ory Network for this feature. Here's an example of how to correctly make this request using curl: bash export PROJECT_ID="your_project_id" export WORKSPACE_API_KEY="your_workspace_api_key" curl -X GET --location "<https://api.console.ory.sh/projects/$PROJECT_ID/organizations>" \ -H "Authorization: Bearer $WORKSPACE_API_KEY"
If you're still encountering issues after verifying these points, you may want to check the [Ory API Reference](https://www.ory.sh/docs/reference/api) for any updates or changes to the API endpoints. If the problem persists, consider reaching out to Ory support for further assistance.bland-finland-95044
01/10/2025, 7:47 PMbrief-egg-61061
01/10/2025, 7:47 PMbrief-egg-61061
01/10/2025, 7:47 PMlistOrganizations
endpoint specifically requires authentication using a workspace API key (oryWorkspaceApiKey
). 2. Workspace vs Project API keys: The [Ory Network API Keys documentation](https://www.ory.sh/docs/concepts/personal-access-token#workspace-api-keys-vs-project-api-keys) provides a clear distinction between what operations can be performed with Workspace API keys versus Project API keys. It states that only Workspace API keys can be used for "CRUD B2B SSO organizations" (Create, Read, Update, Delete operations on organizations). 3. Base URL difference: The documentation also notes that Workspace API keys use the base URL api.console.ory.sh
, while Project API keys use $<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com>
. The organizations endpoint is part of the Workspace API. 4. Explicit mention: The [B2B Single Sign-On & SAML documentation](https://www.ory.sh/docs/kratos/organizations) specifically mentions that to manage organizations via the API, you need to "create a workspace API key". Given these points, it's clear that you cannot use a regular project API key to get the organizations. You must use a workspace API key for this operation. If you need to perform this operation and only have a project API key, you would need to create a workspace API key in the Ory Console. The process for creating a workspace API key is described in the [Authorizing Ory Network Workspace Admin APIs](https://www.ory.sh/docs/concepts/personal-access-token#authorizing-ory-network-workspace-admin-apis) section of the documentation. Remember, workspace API keys have broader permissions, so they should be handled with extra care and security considerations.bland-finland-95044
01/14/2025, 5:11 PMimport { Configuration, FrontendApi } from "@ory/client";
declare global {
var _oryClient: FrontendApi;
}
class Ory extends FrontendApi {
private static _instance: Ory;
private client: FrontendApi;
constructor() {
super();
this.client = new FrontendApi(
new Configuration({
basePath: process.env.ORY_API_URL,
baseOptions: {
withCredentials: true,
},
})
);
if (process.env.NODE_ENV === "development") {
global._oryClient = this.client;
}
}
public static get instance() {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this._instance) {
this._instance = new Ory();
}
return this._instance.client;
}
}
const client = Ory.instance;
export default client;
ory
.createBrowserLoginFlow({
returnTo: searchParams.get("return_to") || process.env.NEXT_PUBLIC_ORY_CALLBACK_URL,
refresh: true,
})
.then(({ data: oryFlow }) => {
setFlow(oryFlow)
})
await ory
.updateLoginFlow({
flow: flow.id,
updateLoginFlowBody: body,
})
brief-egg-61061
01/14/2025, 5:11 PMbrief-egg-61061
01/14/2025, 5:12 PMwithCredentials: true
in the configuration, which is correct. This ensures that cookies are sent with cross-origin requests. 3. CSRF Token: The error suggests that the CSRF token is missing or incorrect. In your updateLoginFlow
call, you're not explicitly including the CSRF token. To resolve this issue, try the following: 1. Ensure you're mapping the CSRF token from the login flow UI nodes. Look for an input field with the name csrf_token
and the hidden
attribute. 2. Include the CSRF token in your updateLoginFlowBody
. Here's an example of how to do this: typescript const csrfToken = flow.ui.nodes.find( node => node.attributes.name === "csrf_token" )?.attributes.value; const body = { ...formData, csrf_token: csrfToken }; await ory.updateLoginFlow({ flow: flow.id, updateLoginFlowBody: body, });
3. If the issue persists, try clearing your browser cookies and cache, then restart the flow. 4. Ensure you're using the latest version of the @ory/client
package, as older versions might have issues with CSRF handling. 5. Double-check that your Ory project is correctly configured for CORS if you're making cross-origin requests. You may need to [add your domain](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#debug) to the Ory Project settings. If you continue to face issues after implementing these changes, you might want to check the network tab in your browser's developer tools to ensure the CSRF cookie is being set and sent correctly with your requests. For more detailed information on handling CSRF in Ory, refer to the [CSRF troubleshooting documentation](https://www.ory.sh/docs/troubleshooting/csrf). Remember, it's crucial to handle CSRF correctly to maintain the security of your application. If you're still encountering problems after trying these solutions, you may need to reach out to Ory support for more specific assistance with your configuration.bland-finland-95044
01/16/2025, 6:42 PMbrief-egg-61061
01/16/2025, 6:42 PMbrief-egg-61061
01/16/2025, 6:43 PM