OAuth Scopes API
On this page
This feature requires at least an Essentials plan.
1.50.0
This page contains the APIs for managing the OAuth Scopes of an Application.
Create an OAuth Scope#
This API is used to create an OAuth Scope for an Application. Specifying an Id on the URI will instruct FusionAuth to use that Id when creating the OAuth Scope. Otherwise, FusionAuth will generate an Id for the OAuth Scope.
Request#
Create an OAuth Scope with either a randomly generated Id or one you provide on the URI.
OpenAPI Spec
OpenAPI Spec
Request Headers#
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Path Parameters#
applicationIdThe Id of the Application.
scopeIdThe Id to use for the new OAuth Scope. If not specified a secure random UUID will be generated.
Request Body#
scope.data An object that can hold any information about the OAuth Scope that should be persisted.
scope.defaultConsentDetail The default detail to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.
scope.defaultConsentMessage The default message to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.
scope.description A description of the OAuth Scope for internal use.
scope.name The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.
scope.required Determines if the OAuth Scope is required when requested in an OAuth workflow.
{
"scope": {
"data": {
"addedBy": "richard"
},
"defaultConsentDetail": "This will provide the requesting application read-only access to your data",
"defaultConsentMessage": "View your data",
"description": "Provides an application read-only access to a user's data",
"name": "data:read",
"required": true
}
}Response#
The response for this API contains the information for the OAuth Scope that was created.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes. |
Response Body#
scope.applicationId The unique Id of the Application.
scope.data An object that can hold any information about the OAuth Scope that should be persisted.
scope.defaultConsentDetail The default detail to display on the OAuth consent screen if one cannot be found in the theme.
scope.defaultConsentMessage The default message to display on the OAuth consent screen if one cannot be found in the theme.
scope.description A description of the OAuth Scope for internal use.
scope.id The unique Id of the OAuth Scope.
scope.insertInstant The instant that the OAuth Scope was added to the FusionAuth database.
scope.lastUpdateInstant The instant that the OAuth Scope was updated in the FusionAuth database.
scope.name The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.
scope.required Determines if the OAuth Scope is required when requested in an OAuth workflow.
{
"scope": {
"applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
"data": {
"addedBy": "richard"
},
"defaultConsentDetail": "This will provide the requesting application read-only access to your data",
"defaultConsentMessage": "View your data",
"description": "Provides an application read-only access to a user's data",
"id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
"insertInstant": 1712268302394,
"lastUpdateInstant": 1712268302394,
"name": "data:read",
"required": true
}
}Retrieve an OAuth Scope#
This API is used to retrieve a single OAuth Scope for an Application by unique Id.
Request#
Retrieve the OAuth Scope by its Id.
OpenAPI Spec
Request Headers#
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Path Parameters#
applicationIdThe Id of the Application.
scopeIdThe Id of the OAuth Scope to retrieve.
Response#
The response for this API contains a single OAuth Scope.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you requested doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
Response Body#
scope.applicationId The unique Id of the Application.
scope.data An object that can hold any information about the OAuth Scope that should be persisted.
scope.defaultConsentDetail The default detail to display on the OAuth consent screen if one cannot be found in the theme.
scope.defaultConsentMessage The default message to display on the OAuth consent screen if one cannot be found in the theme.
scope.description A description of the OAuth Scope for internal use.
scope.id The unique Id of the OAuth Scope.
scope.insertInstant The instant that the OAuth Scope was added to the FusionAuth database.
scope.lastUpdateInstant The instant that the OAuth Scope was updated in the FusionAuth database.
scope.name The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.
scope.required Determines if the OAuth Scope is required when requested in an OAuth workflow.
{
"scope": {
"applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
"data": {
"addedBy": "richard"
},
"defaultConsentDetail": "This will provide the requesting application read-only access to your data",
"defaultConsentMessage": "View your data",
"description": "Provides an application read-only access to a user's data",
"id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
"insertInstant": 1712268302394,
"lastUpdateInstant": 1712268302394,
"name": "data:read",
"required": true
}
}Update an OAuth Scope#
This API is used to update an existing OAuth Scope.
You must specify all of the properties of the OAuth Scope when calling this API with the PUT HTTP method. When used with PUT, this API doesn't merge the existing OAuth Scope and your new data. It replaces the existing OAuth Scope with your new data.
Utilize the PATCH HTTP method to send specific changes to merge into an existing OAuth Scope.
When updating an OAuth Scope on a universal application, a global API key is required. A tenant-scoped API key is not sufficient for this operation.
Request#
Send the full OAuth Scope with your changes applied.
OpenAPI Spec
OpenAPI Spec
For backward compatibility, a PATCH request with a Content-Type of application/json accepts the same body as the PUT request. FusionAuth merges the request into the existing object:
- FusionAuth keeps every field that the request leaves out, so send only the fields you want to change.
- FusionAuth merges a map, such as
data, by key. To remove a key, set the key tonull. - FusionAuth appends the values in a request array to the existing array, unless this API documents otherwise. An empty array leaves the existing array unchanged, so you can't remove values from an appending array.
- FusionAuth adds each object in an array of objects as a new element. FusionAuth doesn't match the object to an existing element by Id or by position.
- Don't send a value that an array of Ids already contains, such as a key Id or a Tenant Id. Some of these arrays then return a
500status code. - Don't set an array to
null. Depending on the field, FusionAuth clears the array or returns a500status code.
To remove values from an array, PUT the full object, or set the Content-Type to one of the following media types:
application/json-patch+jsonfor JSON Patch (RFC 6902)application/merge-patch+jsonfor JSON Merge Patch (RFC 7396)
For more information, see The PATCH HTTP Method.
Request Headers#
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Path Parameters#
applicationIdThe Id of the Application.
scopeIdThe Id of the OAuth Scope to update.
Request Body#
scope.data An object that can hold any information about the OAuth Scope that should be persisted.
scope.defaultConsentDetail The default detail to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.
scope.defaultConsentMessage The default message to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.
scope.description A description of the OAuth Scope for internal use.
scope.name The name of the OAuth Scope. The name can't be changed. Omit it or send the current name. To rename a scope, create a new scope and delete the old one.
scope.required Determines if the OAuth Scope is required when requested in an OAuth workflow.
{
"scope": {
"data": {
"addedBy": "richard",
"internal": false
},
"defaultConsentDetail": "This scope will provide the requesting application read-only access to your data",
"defaultConsentMessage": "View data",
"description": "Provides an application read access to a user's data",
"required": false
}
}Response#
The response for this API contains the information for the OAuth Scope that was updated.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you're updating doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes. |
Response Body#
scope.applicationId The unique Id of the Application.
scope.data An object that can hold any information about the OAuth Scope that should be persisted.
scope.defaultConsentDetail The default detail to display on the OAuth consent screen if one cannot be found in the theme.
scope.defaultConsentMessage The default message to display on the OAuth consent screen if one cannot be found in the theme.
scope.description A description of the OAuth Scope for internal use.
scope.id The unique Id of the OAuth Scope.
scope.insertInstant The instant that the OAuth Scope was added to the FusionAuth database.
scope.lastUpdateInstant The instant that the OAuth Scope was updated in the FusionAuth database.
scope.name The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.
scope.required Determines if the OAuth Scope is required when requested in an OAuth workflow.
{
"scope": {
"applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
"data": {
"addedBy": "richard",
"internal": false
},
"defaultConsentDetail": "This scope will provide the requesting application read-only access to your data",
"defaultConsentMessage": "View data",
"description": "Provides an application read access to a user's data",
"id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
"insertInstant": 1712268302394,
"lastUpdateInstant": 1712298702394,
"name": "data:read",
"required": false
}
}Delete an OAuth Scope#
This API is used to permanently delete an OAuth Scope.
When deleting an OAuth Scope on a universal application, a global API key is required. A tenant-scoped API key is not sufficient for this operation.
Request#
Delete the OAuth Scope by its Id.
OpenAPI Spec
Path Parameters#
applicationIdThe Id of the Application.
scopeIdThe Id of the OAuth Scope to delete.
Request Headers#
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response#
This API does not return a JSON response body.
| Code | Description |
|---|---|
| 200 | The request succeeded. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you requested doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
Related
API documentation for the FusionAuth Authorize OAuth2 endpoint.
Client Secret reference for FusionAuth OAuth2 endpoints.
API documentation for the FusionAuth Device OAuth2 endpoint.
API documentation for the FusionAuth Introspect OAuth2 endpoint.