FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Retrieve Bearer Token from React to use in Spring

    Scheduled Pinned Locked Moved
    General Discussion
    2
    2
    733
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      zihaojustsimple
      last edited by

      I have just started using FusionAuth. I am currently working in integrating the FusionAuth with React and Spring. I facing problem which I don't know how to retrieve the Bearer Token to be send to Spring in as header "Authorization".

      Here is the code:
      62894453-98b3-442f-b2c4-9cf57f290ead-image.png
      I am test using the user.token variable, but it has "undefined" value when I console it.

      A 1 Reply Last reply Reply Quote 0
      • A
        Alex Patterson @zihaojustsimple
        last edited by

        @zihaojustsimple it looks like this is from the React application making a call to your Spring backend. We would need more code to understand where you are pulling in user.

        You could do this using our React SDK another great place to see this in action is our FusionAuth Example React SDK application.

        If those examples don't get you the information you are looking for I would suggest trying out our TypeScript client.

        When using our Login API you will see that there is a HTTP Only cookie available with the access_token which you will need to make the call to your backend. We recommend passing this into your backend so that you can then verify that this is a valid user using server side code within Spring.

        If none of that works feel free to jump into our Slack community.
        https://fusionauth.io/community

        1 Reply Last reply Reply Quote 0
        • First post
          Last post