SubscribeStart OAuth prototype
DO NOT USE THIS!
This commit is contained in:
parent
6dc8140904
commit
430f225f56
@ -34,6 +34,13 @@ define(
|
|||||||
'user' => 'https://www.patreon.com/api/oauth2/v2/identity',
|
'user' => 'https://www.patreon.com/api/oauth2/v2/identity',
|
||||||
'revoke' => '',
|
'revoke' => '',
|
||||||
'scope' => urlencode('identity identity[email]')
|
'scope' => urlencode('identity identity[email]')
|
||||||
|
),
|
||||||
|
'subscribestar' => array(
|
||||||
|
'login' => 'https://www.subscribestar.com/oauth2/authorize',
|
||||||
|
'token' => 'https://www.subscribestar.com/oauth2/token',
|
||||||
|
'api' => 'https://www.subscribestar.com/api/graphql/v1',
|
||||||
|
'revoke' => '',
|
||||||
|
'scope' => 'subscriber.read+subscriber.payments.read+user.read+user.email.read'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -143,7 +150,8 @@ function fictioneer_get_oauth2_login_links( $label = false, $classes = '', $anch
|
|||||||
['discord', __( 'Discord', 'fictioneer' )],
|
['discord', __( 'Discord', 'fictioneer' )],
|
||||||
['twitch', __( 'Twitch', 'fictioneer' )],
|
['twitch', __( 'Twitch', 'fictioneer' )],
|
||||||
['google', __( 'Google', 'fictioneer' )],
|
['google', __( 'Google', 'fictioneer' )],
|
||||||
['patreon', __( 'Patreon', 'fictioneer' )]
|
['patreon', __( 'Patreon', 'fictioneer' )],
|
||||||
|
['subscribestar', __( 'SubscribeStar', 'fictioneer' )]
|
||||||
);
|
);
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
@ -434,9 +442,9 @@ function fictioneer_oauth2_process() {
|
|||||||
case 'twitch':
|
case 'twitch':
|
||||||
$result = fictioneer_oauth2_twitch( $token_response, $cookie );
|
$result = fictioneer_oauth2_twitch( $token_response, $cookie );
|
||||||
break;
|
break;
|
||||||
// case 'subscribestar':
|
case 'subscribestar':
|
||||||
// $result = fictioneer_oauth_subscribestar( $token_response, $cookie );
|
$result = fictioneer_oauth2_subscribestar( $token_response, $cookie );
|
||||||
// break;
|
break;
|
||||||
default:
|
default:
|
||||||
$result = 'oauth_invalid_channel';
|
$result = 'oauth_invalid_channel';
|
||||||
}
|
}
|
||||||
@ -1179,6 +1187,25 @@ function fictioneer_oauth2_twitch( $token_response, $cookie ) {
|
|||||||
* @return string Result code from fictioneer_oauth2_make_user().
|
* @return string Result code from fictioneer_oauth2_make_user().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function fictioneer_oauth_subscribestar( $token_response, $cookie ) {
|
function fictioneer_oauth2_subscribestar( $token_response, $cookie ) {
|
||||||
// Placeholder
|
// GraphQL query
|
||||||
|
$query = "{ user { id name email email_verified avatar_url } subscriber { subscription { price } } }";
|
||||||
|
|
||||||
|
// Retrieve user data from SubscribeStar
|
||||||
|
$user_response = wp_remote_post(
|
||||||
|
FCN_OAUTH2_API_ENDPOINTS['subscribestar']['api'],
|
||||||
|
array(
|
||||||
|
'headers' => array(
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $token_response->access_token
|
||||||
|
),
|
||||||
|
'body' => array( 'query' => $query ),
|
||||||
|
'blocking' => true,
|
||||||
|
'reject_unsafe_urls' => true,
|
||||||
|
'data_format' => 'body'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fictioneer_oauth2_delete_cookie();
|
||||||
|
wp_die( json_encode( $user_response ) );
|
||||||
}
|
}
|
||||||
|
@ -884,6 +884,16 @@ define( 'FICTIONEER_OPTIONS', array(
|
|||||||
'name' => 'fictioneer_comment_form_selector',
|
'name' => 'fictioneer_comment_form_selector',
|
||||||
'group' => 'fictioneer-settings-general-group',
|
'group' => 'fictioneer-settings-general-group',
|
||||||
'sanitize_callback' => 'sanitize_text_field'
|
'sanitize_callback' => 'sanitize_text_field'
|
||||||
|
),
|
||||||
|
'fictioneer_subscribestar_client_id' => array(
|
||||||
|
'name' => 'fictioneer_subscribestar_client_id',
|
||||||
|
'group' => 'fictioneer-settings-connections-group',
|
||||||
|
'sanitize_callback' => 'sanitize_text_field'
|
||||||
|
),
|
||||||
|
'fictioneer_subscribestar_client_secret' => array(
|
||||||
|
'name' => 'fictioneer_subscribestar_client_secret',
|
||||||
|
'group' => 'fictioneer-settings-connections-group',
|
||||||
|
'sanitize_callback' => 'sanitize_text_field'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -275,6 +275,33 @@ $patreon_tiers = is_array( $patreon_tiers ) ? $patreon_tiers : [];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="fictioneer-card">
|
||||||
|
<div class="fictioneer-card__wrapper">
|
||||||
|
<h3 class="fictioneer-card__header"><?php _e( 'SubScribeStar', 'fictioneer' ); ?></h3>
|
||||||
|
<div class="fictioneer-card__content">
|
||||||
|
|
||||||
|
<div class="fictioneer-card__row">
|
||||||
|
<?php
|
||||||
|
fictioneer_settings_text_input(
|
||||||
|
'fictioneer_subscribestar_client_id',
|
||||||
|
__( 'SubscribeStar Client ID', 'fictioneer' )
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fictioneer-card__row">
|
||||||
|
<?php
|
||||||
|
fictioneer_settings_text_input(
|
||||||
|
'fictioneer_subscribestar_client_secret',
|
||||||
|
__( 'SubscribeStar Client Secret', 'fictioneer' )
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php do_action( 'fictioneer_admin_settings_connections' ); ?>
|
<?php do_action( 'fictioneer_admin_settings_connections' ); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user