R
R
rundll322021-06-05 20:00:54
C++ / C#
rundll32, 2021-06-05 20:00:54

Program freezes when trying to perform JWT authorization with a WP site?

Did everything according to this instruction.
I installed plugins for JWT authorization and REST API, exactly those that are indicated there.
I edited the .htaccess of the site by adding the indicated lines, now it looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

Added the following lines to wp-config.php
define('JWT_AUTH_SECRET_KEY', 'тут токен, который я сам придумал');
define('JWT_AUTH_CORS_ENABLE', true);

Well, an attempt to get a client using the method from the article, on which everything hangs:
private void Button1_Click(object sender, EventArgs e)
        {
            client = GetClient().Result;
        }

        private async Task<WordPressClient> GetClient()
        {
            // JWT authentication
            var client = new WordPressClient(WP_URL);
            client.AuthMethod = AuthMethod.JWT;
            await client.RequestJWToken(ADMIN, PASSWORD);
            return client;
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question