I'm trying to display an image related to one of my objects. When querying through API I get this: <img src="/servlet/servlet.FileDownload?file=<some_image_id>" alt="No doc linked" height="800" width="800" border="0"/>

Now, when I'm logged in to SalesForce I can view the image from my browser using that url. But, without loggin-in I can't.

I've searched through the documentation but I couldn't find my legs and hands, it's very unclear to my taste.

My question is - what do I need to do to be able to display an image on an external site (using auth token or what have you - I just can't find the correct way)?


Are you using rest or soap? Rest, you can use the oAuth response headers to get the instance URL.

Example of the rest headers returned with the access token

    "scope": "id full api openid refresh_token chatter_api",
    "token_type": "Bearer",
    "id_token": "eyJhb...h97hc",

Then you can append the instance_url to the relative URLs received in your call.

If soap, you can use the endpoint in the session object to grab the endpoint IIRC

| improve this answer | |
  • thanks for the fast reply! given I have my client access key and secret how do I get the token or refresh it? is there a documentation you can point me to? – wilfo Dec 26 '16 at 16:53
  • Best resource out there is here: - developer.salesforce.com/page/… - For a complete example of implementing oauth using Apex/VF as an example look here - salesforce.stackexchange.com/questions/85664/… - – Eric Dec 26 '16 at 16:56
  • another question - in the flow you described, where would I put the token I have in the image url? – wilfo Dec 27 '16 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.