jonathan-dejong / simple-jwt-authentication

Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.
GNU General Public License v3.0
87 stars 25 forks source link

Issue installing #1

Closed tribalboy3000 closed 7 years ago

tribalboy3000 commented 7 years ago

Hello, I tried to install 2 times and get this error:

Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 262144 bytes) in /home/mysite/public_html/dev/wp-includes/class-wp-hook.php on line 298

I had to remove it from C-Panel to get my site working again.

jonathan-dejong commented 7 years ago

Hi @tribalboy3000

Hmmm that's interesting.. Do you already have a bunch of Rest API calls happening? I can't really see why the plugin would create an overload to wp-hook. There's nothing strange going on and there are only a few hooks that are being used.

I can't replicate it myself. What other plugins do you have active?

tribalboy3000 commented 7 years ago

image

jonathan-dejong commented 7 years ago

Should be this link: https://github.com/jonathan-dejong/simple-jwt-authentication/archive/master.zip and rename it so it's without -master at the end of the folder.

tribalboy3000 commented 7 years ago

Ok I will try that, the one I downloaded was from here: https://github.com/jonathan-dejong/simple-jwt-authentication

jonathan-dejong commented 7 years ago

It's the same, but it looked like you grabbed the develop branch. Could you also try adding these to your wp-config.php before activating?

define( 'SIMPLE_JWT_AUTHENTICATION_SECRET_KEY', 'YOURKEY' ); 
define( 'SIMPLE_JWT_AUTHENTICATION_CORS_ENABLE', true );
tribalboy3000 commented 7 years ago

Ok so now I am able to get it installed but get this:

image

In wp-config I've add: define( 'SIMPLE_JWT_AUTHENTICATION_SECRET_KEY', YOURKEY ); define( 'SIMPLE_JWT_AUTHENTICATION_CORS_ENABLE', true );

htaccess I added:

JWT

RewriteEngine on RewriteCond %{HTTP:Authorization} ^(.) RewriteRule ^(.) - [E=HTTP_AUTHORIZATION:%1]

Request: Request URL:https://mysite.com/dev/wp-json/simple-jwt-authentication/v1/token

Request payload: password:"mypwd" username:"myusername"

I did use the same key as the old JWt, could that be the issue?

jonathan-dejong commented 7 years ago

Hi,

No that should not be an issue. Are you sure that you need the htaccess stuff?

Also, you're not using that request url? Is it really the one to your development project or just for obfuscating it here?

tribalboy3000 commented 7 years ago

I'm just obfuscating it. I had it (htaccess stuff) already added from the old JWT, so I just left it.

jonathan-dejong commented 7 years ago

Hmm.. That error only occur if the secret key isn't available. Could you error_log what happens inside includes/class-simple-jwt-authentication-api.php in the function get_key() on row 51. Replace it with this and make sure you have turned on wp_debug in wp-config.php

public static function get_key() {
    error_log( 'inside get_key' );
    if ( defined( 'SIMPLE_JWT_AUTHENTICATION_SECRET_KEY' ) ) {
        error_log( 'Returning from constant' );
        return SIMPLE_JWT_AUTHENTICATION_SECRET_KEY;
    } else {
        error_log( 'Fetching from settings.' );
        $settings = Simple_Jwt_Authentication_Api::get_db_settings();
        if ( $settings ) {
            error_log( 'returning from settings' );
            return $settings['secret_key'];
        }
    }
    error_log( 'nothing found, returning false.' );
    return false;

}
tribalboy3000 commented 7 years ago

Oh my god, I was in the wrong wp-config. It's working! Sorry for wasting your time and thank you for taking over this project!

Just checked the user profile and LOVE what you did!

jonathan-dejong commented 7 years ago

Hahaha shit happens.

Have a break and a cup of coffee!

tkserver commented 7 years ago

Been there before haha.