melodic-oil-50942
05/09/2024, 1:36 PMchilly-king-10285
05/09/2024, 1:36 PMchilly-king-10285
05/09/2024, 1:37 PMexternal_url
in the GitLab configuration to match the generated callback URL. Sources: - [OAuth2 fundamentals](https://www.ory.sh/docs/oauth2-oidc/overview/oauth2-concepts#creating-oauth2-clients) - [GitLab configuration - OAuth 2 setup](https://www.ory.sh/docs/hydra/self-hosted/gitlab#gitlab-configuration---oauth-2-setup)melodic-oil-50942
05/09/2024, 1:49 PM{
"id": "invalid_request",
"error": {
"status": "OAuth2 Error",
"id": "invalid_request",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. The 'redirect_uri' parameter does not match any of the OAuth 2.0 Client's pre-registered redirect urls.",
"code": 599
}
}
I understand that i need to pre-register that url but i don't see that setting in my ory-project.dev.json
, how do i pre-register it? Do i need to create a new oauth2 client?chilly-king-10285
05/09/2024, 1:49 PMchilly-king-10285
05/09/2024, 1:49 PMredirect_uri
you're using doesn't match any of the redirect URIs that were pre-registered for your OAuth2 client. To pre-register a new redirect_uri
, you need to update your OAuth2 client's configuration. You can do this using the Ory Console, Ory CLI, Ory SDK, or REST API. Here's how you can do it using the Ory CLI: bash ory update oauth2-client {client.id} \ --redirect-uri <https://a-new-callback>
Replace {client.id}
with your OAuth2 client's ID and <https://a-new-callback>
with your new callback URL. If you're using the Ory SDK, you can use the setOAuth2Client
function to update your OAuth2 client's configuration: javascript import { Configuration, OAuth2Api, OAuth2Client } from "@ory/client" const ory = new OAuth2Api( new Configuration({ basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`, accessToken: process.env.ORY_API_KEY, }), ) export async function updateOAuth2Client( id: string, update: Partial<OAuth2Client>, ) { // setOAuth2Client replaces all values (empty ones too), // which is why we include the original client. const { data: original } = await ory.getOAuth2Client({ id }) await ory.setOAuth2Client({ id, oAuth2Client: { ...original, ...update, }, }) }
In this code, replace id
with your OAuth2 client's ID and update
with your new callback URL. You don't need to create a new OAuth2 client unless you want to use a different set of configurations. For more information, refer to the [Ory documentation on updating an OAuth2 client](https://www.ory.sh/docs/hydra/guides/oauth2-clients#update-oauth2-client).melodic-oil-50942
05/09/2024, 1:57 PMchilly-king-10285
05/09/2024, 1:57 PMchilly-king-10285
05/09/2024, 1:57 PMory update oauth2-client
command, it expects the client ID as the only positional argument. The --redirect-uri
is an option, not an argument. Here's the correct syntax: bash ory update oauth2-client {client.id} --redirect-uri <https://a-new-callback>
Replace {client.id}
with your OAuth2 client's ID and <https://a-new-callback>
with your new callback URL. If you're still encountering issues, please refer to the [Ory CLI documentation](https://www.ory.sh/docs/cli/ory-update-oauth2-client#ory-update-oauth2-client) for more information.melodic-oil-50942
05/09/2024, 1:59 PMchilly-king-10285
05/09/2024, 1:59 PMchilly-king-10285
05/09/2024, 1:59 PM--project
flag followed by your project ID or slug. Here's how you can do it: bash ory update oauth2-client {{client.id}} --redirect-uri <https://a-new-callback> --project {{project.id}}
Replace {{client.id}}
with your OAuth2 client's ID, <https://a-new-callback>
with your new callback URL, and {{project.id}}
with your project ID or slug. If you're frequently working with the same project, you can set it as the default project using the ory use project
command: bash ory use project {{project.id}}
Replace {{project.id}}
with your project ID or slug. This will set the specified project as the default for future commands. For more information, please refer to the [Ory CLI documentation](https://www.ory.sh/docs/cli/ory-update-oauth2-client#ory-update-oauth2-client) and [Ory use project documentation](https://www.ory.sh/docs/cli/ory-use-project#ory-use-project).melodic-oil-50942
05/09/2024, 2:35 PMchilly-king-10285
05/09/2024, 2:35 PMchilly-king-10285
05/09/2024, 2:36 PMread:badges
) that it's not allowed to request. In OAuth2, scopes are used to specify the level of access that a client has to a user's resources. They are included in the authorization request and must be allowed by both the OAuth2 server and the user. If you're seeing this error, it means that the read:badges
scope is either not supported by the OAuth2 server or not allowed for the client. To resolve this issue, you can do one of the following: 1. Remove the read:badges
scope from your authorization request if it's not necessary for your application. 2. If the read:badges
scope is necessary, check your OAuth2 server's configuration to ensure that this scope is supported and allowed for your client. You might need to update your client's configuration to include this scope. Here's how you can update your client's configuration using the Ory CLI: bash ory update oauth2-client {{client.id}} --allowed-scope read:badges --project {{project.id}}
Replace {{client.id}}
with your OAuth2 client's ID and {{project.id}}
with your project ID or slug. For more information, please refer to the [Ory documentation on OAuth2 scopes](https://www.ory.sh/docs/oauth2-oidc/overview/oauth2-concepts#oauth2-scopes-represent-user-consent) and [updating an OAuth2 client](https://www.ory.sh/docs/hydra/guides/oauth2-clients#update-oauth2-client).melodic-oil-50942
05/09/2024, 2:41 PMchilly-king-10285
05/09/2024, 2:41 PMchilly-king-10285
05/09/2024, 2:42 PM--allowed-scope
flag is not a valid option for the ory update oauth2-client
command. In Ory, scopes are not directly associated with clients but are part of the OAuth2 and OpenID Connect protocols. They are used in requests made by the client, and the server decides whether a scope is valid or not. If you're seeing an invalid_scope
error, it's likely that the scope read:badges
is not recognized by the server. You should check the server's configuration or the service you're integrating with to ensure that read:badges
is a valid scope. If read:badges
is a custom scope you've defined, make sure it's correctly configured in your server. If it's a scope defined by a third-party service, check their documentation to ensure you're using it correctly. For more information about scopes in Ory, you can refer to the [Ory documentation on OAuth2 scopes](https://www.ory.sh/docs/oauth2-oidc/overview/oauth2-concepts#oauth2-scopes-represent-user-consent).