We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Passing keycloak username and token to the getimage api of backend

Hey there.

We want to pass keycloak username and token to the getImageurl api. Please help us in this regard.


1 Reply

SS Sivakumar ShunmugaSundaram Syncfusion Team December 12, 2022 04:30 PM UTC

Hi Jyoti,


Greetings from Syncfusion support.


With the shared details, you need to pass the JWT token from the client to the server side in the React FileManager GetImage operation. We would like to let you know that we can’t add the JWT token with this request. However, we have used the Query parameter for the GetImage operations of the FileManager component. To achieve your requirement, you just need to use the below code details in the FileManager beforeImageLoad event.


Refer to the below code snippet.

[index.js],

 

export class Overview extends SampleBase {

  onbeforeImageLoad(args) {

    // Add custom parameter in image URL

    args.imageUrl = args.imageUrl + '&rootName=' + 'TokenValue';

  }

  hostUrl = 'http://localhost:62869/';

  render() {

    return (

      <div>

        <div className="control-section">

          <FileManagerComponent

            id="overview_file"

...

            }}

            view={'Details'}

            beforeImageLoad={this.onbeforeImageLoad}

          >

            <Inject services={[NavigationPane, DetailsView, Toolbar]} />

          </FileManagerComponent>

...

 


[FileManager.Controller.cs],

 

namespace EJ2APIServices.Controllers

{

    public class FileManagerDirectoryContent1

    {

...

        public string rootName { get; set; }

...

public IActionResult GetImage(FileManagerDirectoryContent1 args)

        {

            var root = args.rootName;

            return this.operation.GetImage(args.Path, args.Id,false,null, null);

        } 


Sample: https://stackblitz.com/edit/react-ztpxhq?file=index.js,index.html


Service provider: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ej2-aspcore-file-provider2082500053.zip


Check out the attached sample for your reference.


Loader.
Live Chat Icon For mobile
Up arrow icon