• To apply the oauth function to the rest api, I set it as follows.
    https://localhost/customdev/oauthcb/authorization_code-1.php

    
    # authorization_code-1.php
    <?php
    
    # require('Client.php');
    # require('GrantType/IGrantType.php');
    # require('GrantType/AuthorizationCode.php');
    
    require("vendor/autoload.php");
    
    const CLIENT_ID     = 'U988ri1rs3XRZVrqwOAxXLi3QjmUu3TKBlOUTGZ8';
    const CLIENT_SECRET = 'O0jXuRxwHt1Kcq3uZWG0AouefXupgvrJp7mYKqqq';
    
    const REDIRECT_URI           = 'https://localhost/customdev/oauthcb/authorization_code-1.php';
    const AUTHORIZATION_ENDPOINT = 'https://localhost/oauth/authorize';
    const TOKEN_ENDPOINT         = 'https://localhost/oauth/token';
    
    $client = new OAuth2\Client(CLIENT_ID, CLIENT_SECRET);
    if (!isset($_GET['code']))
    {
        $auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI);
        header('Location: ' . $auth_url);
        die('Redirect');
    }
    else
    {
        $params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI);
        $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);
    
        echo "<pre>";
        print_r($response);
    
        # parse_str($response['result'], $info);
        # $client->setAccessToken($info['access_token']);
        # $response = $client->fetch('https://graph.facebook.com/me');
        # var_dump($response, $response['result']);
    }
    

    https://wp-oauth.com/docs/how-to/setup-wp-oauth-server-for-single-sign-on-with-wordpress/
    There is a similar example, so I followed it. It doesn’t seem to work.

    However, different from the applied value, it is redirected to /wp-login.php

    I set it to two things, authorization_code and implicit.
    I also turned off the “jetpack brute force protection” feature.
    I’ve tested it on both staging and production sites and it doesn’t works.
    (The staging site is a subdomain method)

    Why doesn’t works?
    Why do I keep redirecting to wp-login?

    The docs docs do not provide detailed explanations for these issues.

    • This topic was modified 4 years, 7 months ago by sinho0689.
    • This topic was modified 4 years, 7 months ago by sinho0689.
    • This topic was modified 4 years, 7 months ago by sinho0689.
Viewing 1 replies (of 1 total)
  • Plugin Author Justin Greer

    (@justingreerbbi)

    I can only speak to WP OAuth Server but the plugin will redirect to wp-login.php so that the user can authorize the client first. This should only happen once during an active session.

    Once a user authorizes (logs in), the redirect will happen but then will redirect back to your assigned redirect url value.

Viewing 1 replies (of 1 total)
  • The topic ‘Why keep redirecting to wp-login?’ is closed to new replies.