quick-addition-90714
09/20/2024, 7:05 PMbrief-egg-61061
09/20/2024, 7:05 PMbrief-egg-61061
09/20/2024, 7:06 PMbash docker run --rm -it --network hydraguide oryd/hydra:v2.0.1 \ create oauth2-client \ --endpoint <http://ory-hydra-example--hydra:4445> \ --grant-type client_credentials
This command will output the OAuth2 Client details, including the client_id
and client_secret
. Make sure to save these for later use. 2. Perform the client credentials grant: You can then use the client credentials grant to get an access token. Here's how to do it with the Ory Hydra CLI: bash docker run --rm -it --network hydraguide oryd/hydra:v2.0.1 \ perform client-credentials \ --client-id {INSERT-CLIENT-ID_HERE} \ --client-secret "{INSERT-CLIENT-SECRET-HERE}" \ --endpoint <http://ory-hydra-example--hydra:4444>
This command will output an OAuth2 access token. You can use this token to authenticate your requests to your API. 3. Validate the access token: Finally, you can validate the access token using the hydra introspect token
command: bash docker run --rm -it --network hydraguide oryd/hydra:v2.0.1 \ introspect token \ --endpoint <http://ory-hydra-example--hydra:4445> \ "{INSERT-ACCESS-TOKEN-HERE}"
This command will output the OAuth2 access token metadata, including whether the token is active. For more detailed information, you can refer to the [Ory Hydra documentation](https://www.ory.sh/docs/hydra/sdk/go#createoauth2client-and-listoauth2clients) and the [Ory Network OAuth2 quickstart guide](https://www.ory.sh/docs/getting-started/ory-network-oauth2). Please replace {INSERT-CLIENT-ID_HERE}
, {INSERT-CLIENT-SECRET-HERE}
, and {INSERT-ACCESS-TOKEN-HERE}
with your actual client_id
, client_secret
, and access_token
respectively. Sources: - [Performing the OAuth2 Client Credentials Flow](https://www.ory.sh/run-oauth2-server-open-source-api-security/#performing-the-oauth2-client-credentials-flow) - [Ory Network OAuth2 quickstart guide](https://www.ory.sh/docs/getting-started/ory-network-oauth2)