This is a migrated thread and some comments may be shown as answers.

JWT authentication and images

3 Answers 514 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rémi
Top achievements
Rank 1
Veteran
Rémi asked on 11 Jun 2020, 07:34 AM

Hi,

My app needs authentication and I use JWT.

Is want to populate a TreeView with some personal image, but the question stay open for all component with ImageUrlField property

 

How to query an image url that contains the JWT token, ie in the header

Authorization: Bearer <token>

?

Thanks

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 11 Jun 2020, 08:29 AM

Hello Rémi,

How would you use an <img /> tag and include this token in your app? I am not aware of a built-in way to do that and at this point my best suggestion is that you implement a Razor Component that provides this capability as required by your situation, and use it in a template in the Telerik component (link to the treeview templates examples).

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Accepted
Rémi
Top achievements
Rank 1
Veteran
answered on 13 Jun 2020, 06:51 AM

Thanks Marin,

The work around I found is to use HttpClient to download the image stream and set URL like this

string urlField { get {

... HttpClient logic here ...

string imageBase64Data = Convert.ToBase64String(ms.ToArray());
return string.Format("data:image/jpeg;base64,{0}", imageBase64Data);

} }

Rémi

 
0
Marin Bratanov
Telerik team
answered on 13 Jun 2020, 07:22 AM

Hello Rémi,

I expected this would be the general approach. I have marked your post as an answer to this thread.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Rémi
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Rémi
Top achievements
Rank 1
Veteran
Share this question
or