PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / myyoast-client / application / grants / client-credentials-grant.php

client-credentials-grant.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/myyoast-client/application/grants/client-credentials-grant.php

65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
4 namespace Yoast\WP\SEO\MyYoast_Client\Application\Grants;
5
6 /**
7 * Grant strategy for the Client Credentials flow (RFC 6749 Section 4.4).
8 *
9 * Used for site-level tokens without user context.
10 * Includes the site URL for site identity.
11 */
12 class Client_Credentials_Grant implements Grant_Interface {
13
14 /**
15 * The scopes to request.
16 *
17 * @var string[]
18 */
19 private $scopes;
20
21 /**
22 * The site URL for site identity.
23 *
24 * @var string
25 */
26 private $site_url;
27
28 /**
29 * Client_Credentials_Grant constructor.
30 *
31 * @param string[] $scopes The scopes to request.
32 * @param string $site_url The site URL.
33 */
34 public function __construct( array $scopes, string $site_url ) {
35 $this->scopes = $scopes;
36 $this->site_url = $site_url;
37 }
38
39 /**
40 * Returns the grant type identifier.
41 *
42 * @return string
43 */
44 public function get_grant_type(): string {
45 return 'client_credentials';
46 }
47
48 /**
49 * Returns the grant-specific parameters.
50 *
51 * @return array<string, string>
52 */
53 public function get_grant_params(): array {
54 $params = [
55 'site_url' => $this->site_url,
56 ];
57
58 if ( ! empty( $this->scopes ) ) {
59 $params['scope'] = \implode( ' ', $this->scopes );
60 }
61
62 return $params;
63 }
64 }
65