title: JWT Token does not begin with Bearer String ,and in axioms when sending it began with Bearer
body: <p>I'm trying to send a post request sending the token in the header and also as a string. The problem is authenticating the header in the backend gives me the error <code>JWT Token does not begin with Bearer String</code>.</p>
  <p>Below is the relevant code.</p>
  <p><strong>Frontend</strong></p>
  <pre><code>    getUser() {
          if (token != null) {
              const config = {
                  headers: { Authorization: `Bearer ${token}` }
              };
  
              const formData = new FormData();
              formData.set(&quot;token&quot;, token);
              
              axios.post(&quot;http://localhost:8080/user/token&quot;, formData,config)
                  .then((function (response) {
                      if (response.data.email !== null) {
  
                          sessionStorage.setItem(&quot;role&quot;, response.data.role);
                          sessionStorage.setItem(&quot;userId&quot;, response.data.id);
                          sessionStorage.setItem(&quot;name&quot;, response.data.name);
  
                          location.reload(true)
                          document.getElementById('loginResult').innerHTML = response.data.token;
                      }
  
                  }));
          }
  
      }
  </code></pre>
  <p><strong>Backend</strong></p>
  <pre><code>  protected void configure(HttpSecurity httpSecurity) throws Exception {
                // We don't need CSRF for this example
          httpSecurity
                  .csrf().disable()
                // dont authenticate this particular request
                  .authorizeRequests()
                  .antMatchers(&quot;/authenticate&quot;).permitAll()
                  .antMatchers(&quot;/events&quot;).permitAll()
                  .antMatchers(&quot;/events/**&quot;).hasAnyAuthority(&quot;ADMIN&quot;,&quot;VENDOR&quot;)
                  .antMatchers(&quot;/event-photos/**&quot;).permitAll()
                  .antMatchers(&quot;/user/**&quot;).hasAnyAuthority(&quot;ADMIN&quot;,&quot;VENDOR&quot;)
                  .anyRequest().authenticated()
                  .and()
               // make sure we use stateless session; session won't be used to
               // store user's state.
                 .exceptionHandling()
                  .authenticationEntryPoint(jwtAuthenticationEntryPoint)
                  .and().sessionManagement()
                  .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
  
               // Add a filter to validate the tokens with every request
          httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
  
      }
  </code></pre>
  <pre><code>    @PostMapping(&quot;user/token&quot;)
      public @ResponseBody User getUser(@RequestParam(&quot;token&quot;) String token){
          String email=jwtTokenUtil.getUsernameFromToken(token);
          User user=userRepository.getUserByUsername(email);
          return user ;
      }
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/HvGTn.png" rel="nofollow noreferrer">Google Inspect picture for the request </a></p>