You can configure the Upstream OAuth plugin to use Kong Identity as the identity provider for your Gateway Services. In this example, you’ll apply the plugin to the control plane globally, but you can alternatively apply it to a Gateway Service.
First, get the ID of the quickstart control plane you configured in the prerequisites:
curl -X GET "https://us.api.konghq.com/v2/control-planes?filter%5Bname%5D%5Bcontains%5D=quickstart" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN"
Export the control plane ID:
export CONTROL_PLANE_ID='YOUR-CONTROL-PLANE-ID'
Enable the Upstream OAuth plugin globally:
curl -X POST "https://us.api.konghq.com/v2/control-planes/$CONTROL_PLANE_ID/core-entities/plugins/" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN"\
-H "Content-Type: application/json" \
--json '{
"name": "upstream-oauth",
"config": {
"oauth": {
"token_endpoint": "'$ISSUER_URL'/oauth/token",
"grant_type": "client_credentials",
"client_id": "'$CLIENT_ID'",
"client_secret": "'$CLIENT_SECRET'",
"scopes": [
"Scope"
]
},
"behavior": {
"upstream_access_token_header_name": "Authorization"
}
}
}'