• I am working on my localhost. I have installed this plugin and setup client php library on other side from that side I am trying to fetch my custom route. But I am unable to do this when I am not logged in to the wordpress.

    Please guide me.

Viewing 1 replies (of 1 total)
  • Hi
    I have the same problem.
    actually, I use the jso.js library for a javascript client on another side.
    but it dose not work currectly.
    I installed the OAuth Server plugin and create a client. also, I checked the Authorization Code, Implicit and Allow Implicit options.
    there is my WordPress site.
    there is a client
    and here is my client configuration js code:

    
    // Based on https://github.com/andreassolberg/jso/tree/version3
    
    var ROOTURL = 'https://fenchgroup.com';
    const RESTROOT = ROOTURL + '/wp-json';
    const RESTROUTE = RESTROOT + '/wp/v2/tasks/';
    
    var jso = new JSO({
    	providerID: "fenchi",
    	client_id: "sO05Jc85OA19V2HUe6GJ2caIYaX0rQ3UF4Zoh8u5",
    	redirect_uri: "https://wpro.ir/taskapp/tasklist.html",
    	authorization: ROOTURL + "/oauth/authorize",
    	debug: true
    });
    
    // Catch the response after login:
    jso.callback();
    
    var token = localStorage.getItem('tokens-fenchi');
    
    // Trigger OAuth 2 authentication sequence:
    function oauthLogin() {
    
    	jso.getToken();
    }
    
    // Log out and wipe all memory of the session:
    function oauthLogout() {
    	jso.wipeTokens();
    }
    
    // Monitor the login button:
    $('#login').click(function() {
        oauthLogin();
    });
    
    // Monitor the logout button:
    $('#logout').click(function() {
        oauthLogout();
    	window.location.href = "/";
    });
    
    (function() {
    	// If we are on the home page, redirect to tasklist.html:
    	if ( location.pathname == "/" ) {
    		// If we have a token, assume we're logged in:
    		if ( token !== null ) {
    			window.location.href = "/tasklist.html";
    		}
    
    	} else {
    		// If we have a token, assume we're logged in:
    		if ( token !== null ) {
    			// Enable JSO jQuery wrapper:
    			JSO.enablejQuery($);
    		} else {
    			// If we're not logged in, redirect to the login page:
    			window.location.href = "/";
    console.log(token);
    		}
    	}
    })();
    
    

    I tested on localhost and a real host. both of theme has the same problem and doesn’t work.

    I will glad to hear your advice.

    • This reply was modified 6 years, 2 months ago by fenchgroup. Reason: edit links
    • This reply was modified 6 years, 2 months ago by fenchgroup.
Viewing 1 replies (of 1 total)
  • The topic ‘oAuth server unable to get code redirecting to wp-login’ is closed to new replies.