Excel – PingAccess hyerlink redirect issue

I hope that most of you got an error If you embedded an authentication enabled hyperlink in excel file(https://support.microsoft.com/en-us/kb/218153)

I have also got the same issue in my Rest application. My rest application generates a report in excel format which contains a hyperlink to view other information which is dynamically updated multiple times in a day and it’s an another Rest service. So the user has to click on that link to view more content. the user has to authenticate himself before proceeding. We use Ping Access to authenticate the user. So once the user clicks on that link, the user will be shown with a login page and upon entering the valid login credentials, he/she will be landed on the more information service.

The flow will be like.
Excel == > Login Page == > Target Service

As we know that the excel does not follow the browser redirect hence it’s not allowing me to open the target page

We have followed the below approach to resolving this issue. I hope that this will also help others.

1. I have created a redirect Rest service which will take the service URI information. If you look carefully you can come to know that the below service takes the serviceUri and replace that URL in the REDIRECT_CONTENT string and return that whole HTML to the browser.

For example

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

public class RedirectService {

        private static final String REDIRECT_CONTENT = "<html><head> <title>%s</title> <meta http-equiv=\"refresh\" content=\"0;URL='%s'\" /></head> <body> <p>Redirecting</p></body></html>";

        public Response redirect(@QueryParam("serviceUri") String serviceUri) {
            return Response.status(200).entity(String.format(REDIRECT_CONTENT, serviceUri)).build();

2. The next step is to embed the redirect service URL in the excel report instead of the actual target service URL and make sure that you pass the actual service URL as a query parameter. Assume that the hyperlink will be like below,

Assume that 1234234 is a unique id, in this case, it a content id

3. Make some changes in Ping access to disable the authentication for this service(/service/redirect)

That’s it. We are done. So when the user clicks on the link from the excel, it will just open up a browser window and don’t show anything but on the back end, the META refresh will work and will redirect the user to /service/content/1234234 as this service is authentication enabled, so it just shows up the login page and upon entering the login credentials it will take you to the target page

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s