Screenshot WOW SAVE 20% on the All Access Bundle. Use "OAUTH20OFF" at checkout.
GET DEAL
3rd Party Integration

Adding Supported Scopes

Published: February 28, 2020 | Updated: November 9th, 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_custom_scopes_filter_function' );
function wo_custom_scopes_filter_function( $scopes ) {
    // your scopes you want to add
    $my_scopes = array( 'scope1', 'scope2' );	
    
    $new_scopes = array_merge( $scopes, $my_scopes );	
    
    return $new_scopes;
}

Icon