How can I add a Bearer token to the Auth headers?

Hello, I am happy this feature has been released, but I am not sure how to include my bearer token in the project. I have placed it like this in the frontity.settings.js, with no success.

 {
  name: "@frontity/wp-source",
  state: {
    source: { 
      api: .....
      params: {
        per_page: 30,
        type: ["post", "page"],            
      },
     auth: 'Bearer my token'

I am a new in Frontity so sorry if my question is too basic. Thanks in advance!

Hi @elisenda,

Welcome to the community!
I’ve moved this thread to this category.

Sorry, for the lack of documentation regarding this. It’s in the roadmap and this feature will be properly documented as soon as possible.

In the meantime the information to use this feature can be found in the Feature Discussion in the documentation PR

The code you share seems to be right. For a token for example like sdf98sd7f9sf7s98f7sd9f87sd98fsd the code will be

{
  name: "@frontity/wp-source",
  state: {
    source: { 
      api: .....
      params: {
        per_page: 30,
        type: ["post", "page"],            
      },
     auth: 'Bearer sdf98sd7f9sf7s98f7sd9f87sd98fsd'

Can you please provide a repo or code-sandbox with your code? This is especially helpful to find solutions of technical issues with specific code

@juanma, now that WordPress 5.6 is out and includes application passwords we need to show people how to use them to make the preview work in Decoupled mode :slightly_smiling_face:

1 Like

Been using Application password since 5 months in my frontity project, you just have to be careful to not expose it on the client side.

1 Like