Screenshot COVID-19 Update We have changed are structure to better support our employees and customers through these hard times.
See Updates

Adding Supported Scopes

Published: February 28, 2020 | Updated: February 28th, 2020
  1. Home
  2. Docs
  3. How To
  4. Adding Supported Scopes

Overview

Scopes in OAuth 2 are ways to control which data is available to the resource API when a request is made. Out of the box, WP OAuth Server does not support scopes regarding data limitations but does support them in the settings. Basically, you can use scopes but the plugin itself does not restrict data with any of its default API endpoints.

In most cases when scopes are used for WP OAuth Server, it is when custom endpoints are being used. Scopes can be added to an allowed list by visiting a client’s editor window and using the allowed scopes field.

By default, WP OAuth Server supports 4 scopes.

  • openid
  • profile
  • email
  • basic

If you would like to add more scopes or modify the scopes that can be used, you have the option to use the wo_scopes filter.

Add New Supported Scopes

add_filter( 'wo_scopes', 'wo_example_scopes_filter' );
function wo_example_scopes_filter( $scopes ) {
    // your scopes you want to add
    $my_scopes = array( 'scope1', 'scope2' );	
    
    $new_scopes = array_merge( $scopes, $my_scopes );	
    
    return $new_scopes;
}

Icon