Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need gatsby-source-wordpress to support jwt authentication #6879

Closed
ytwguru opened this issue Jul 31, 2018 · 9 comments · Fixed by #9509
Closed

Need gatsby-source-wordpress to support jwt authentication #6879

ytwguru opened this issue Jul 31, 2018 · 9 comments · Fixed by #9509
Labels
good first issue Issue that doesn't require previous experience with Gatsby

Comments

@ytwguru
Copy link

ytwguru commented Jul 31, 2018

Summary

I would like the gatsby-source-wordpress to support jwt authentication

Basic example

If possible, the gatsby-config for the plugin will include the potential to authenticate with the token

auth: {
  // If jwt_token is filled, then the source plugin will be allowed
  // to access endpoints that are accessible with a valid token.
  jwt_token : ""
}

Motivation

We use the jwt-authentication-for-wp-rest-api plugin for a project, but the gatsby-source-wordpress plugin only supports .htaccess and wordpress authentication.

@KyleAMathews
Copy link
Contributor

Sounds great! Could you add a PR?

@ytwguru
Copy link
Author

ytwguru commented Jul 31, 2018

Sure thing.

@sarahannnicholson
Copy link
Contributor

Hey! This seems like a great feature! Just a little curious about the progress?

@DSchau DSchau added the good first issue Issue that doesn't require previous experience with Gatsby label Oct 23, 2018
@ghost
Copy link

ghost commented Oct 28, 2018

Since there doesn't seem to be any progress, I'll try to figure this one out. 🤓

@sarahannnicholson
Copy link
Contributor

hmm quick question, how would one make a jwt authenticated request to wordpress?
I had a peek at the gatsby-source-wordpres docs and couldn't find an example.
I was hoping to see some queries in GraphQL?

@ghost
Copy link

ghost commented Jan 9, 2019

The authentication and usage of the token happens automatically behind the scenes, so you don't need to explicitly do anything different when using JWT authentication.

@sarahannnicholson
Copy link
Contributor

Behind the scenes? hmm.
I think I'm still missing something. From what I understand, jwt extends the WP REST API. And I'd like to get data from one of the extended endpoints: ie)
{wp-domain}/wp-json/wp/v2/alerts?status=draft
This jwt-authentication feature is great cause now we don't need to worry about getting a token. But how do I get data from the extended endpoints? I didn't notice any new queries in my GraphiQL, and if I make a fetch in JavaScript it gives me an error unless I explicitly set the token in the request header.

@ghost
Copy link

ghost commented Jan 10, 2019

Is this comment relevant? #9509 (comment)

@watzing also one thing - this adds support for jwt authorization - but it doesn't change endpoints that this plugin use.

F.e. we grab posts using /wp-json/wp/v2/posts route (which even with authorization will only show published posts). To get also drafts we would need to use /wp-json/wp/v2/posts?status=any or /wp-json/wp/v2/posts?status=publish,future,draft,pending (not really that familiar with some available options that wp-json shows):

publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, any

But right now wordpress plugin doesn't support applying filters like that - this would need to be implemented separately

@sarahannnicholson
Copy link
Contributor

ahh okay, yes that is exactly what I was trying to do :P thanks so much for the clarification!

gpetrioli pushed a commit to gpetrioli/gatsby that referenced this issue Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants