this returned me the service metadata but when i clicked "View in ArcGIS Javascript", another browser window got opened and started asking for user name and password to access the service.
So when i already provided the token then why it is again asking for user name and password.
My guess is that the token is not being passed when you click view in Javascript. If you add the map service (with the token) into a javascript application does it show the layer?