Using ClientTokens

Last post 2/4/2010 6:55:30 PM by twilliams. 4 replies. << Back to Web.Maps.VE v3.0 General
11/8/2009 2:32:07 PM
Medwyn

Using ClientTokens

I'm trying to work out how to integrate the bing maps token functionality into simplovation.

I've got the following code which appears to be giving me back a token string which i'm setting in the map control, but looking at my usage stats I don't appear to actually be registering any tokens.

 

CommonService commonservice = new CommonService();

commonservice.Url = "https://staging.common.virtualearth.net/find-30/common.asmx";

commonservice.Credentials = new System.Net.NetworkCredential("<account>", "<password>");

TokenSpecification tokenspec = new TokenSpecification();

tokenspec.ClientIPAddress = Page.Request.UserHostAddress;

tokenspec.TokenValidityDurationMinutes = 480;

string clientoken = commonservice.GetClientToken(tokenspec);

divMapHolder.ClientToken = clientoken;

 

Any help appreciated.

Cheers.

11/20/2009 2:23:02 PM
Chris Pietschmann

Re:Using ClientTokens

Where are you setting the ClientToken for the Map? Make sure you are setting it within the Page Load event, it needs to be set before the Map is rendered to the page on the initial page load.

Also, could you please check that the generated token gets placed into the page by looking at the page source? If it's not there, please post some example code that exhibits the issue, so I can help troubleshoot it and fix this if necessary.
11/29/2009 2:36:28 PM
Medwyn

Re:Using ClientTokens

I've checked the page source and it doesn't appear to have any signs of the token in it.

I've got the code posted above as the first thing that runs in the page load on the page.

I'll try creating a project that simply displays a map and try getting the token into that and post the complete code here should that not work.

Have you got any example code that uses tokens that I could check out while i'm doing that?

 

Thanks,

Medwyn

12/10/2009 5:34:17 PM
Chris Pietschmann

Re:Using ClientTokens

Did you get this working? Or, are you still having issues?
2/4/2010 6:55:30 PM
twilliams

Re:Using ClientTokens

I am having a slightly different issue with the use of client tokens.  My production site is secure using https where the map control is hosted. 

The problem I am encountering is that I am still getting prompted with a security warning when the page hosting the map control is rendered.  By clicking "yes" to view the page securely there is a javascript error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; .NET CLR 3.0.30618; .NET CLR 3.5.21022; InfoPath.2; SLCC1; .NET4.0C; .NET4.0E)
Timestamp: Thu, 4 Feb 2010 18:49:15 UTC


Message: 'VEMapMode' is undefined
Line: 14
Char: 5
Code: 0
URI: https://secure.calrecycle.ca.gov/RWMTesting/ScriptResource.axd?d=xQFA-nEJn4WjpmFXu_PQ3GkBz5rzQylFMqje7DoYUnqRe-klKPa4hgKOIx9CYfhbzukmrNVY7cwIo8YRfQLaSw2&t=ffffffffd7e61daa

I set a client token in the Page_Load method as shown in the code below:

protected void Page_Load(object sender, EventArgs e) {
        AddressServices aSrv = new AddressServices();
        if (string.IsNullOrEmpty(token))
            token = aSrv.GetBingClientToken();
        Map1.ClientToken = token;
    }

When the page renders the token is visible in the client source for the page:

...
"ClientToken":"5izMncbIS1lzd3o8JcjjuOICBTYM1Y3VLWi32l3Xwq673KzL7J4PxBeWDrM7Do_j23N2RD4k-Zr9CvM5q-EJmg2"
...

We are pointing to the following URL's for the Bing services and we pay for enterprise map point:
https://common.virtualearth.net/find-30/common.asmx?wsdl
http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl


My goal is to be able to view the map on the secure page without getting the security warning.  I was under the impression that by using the Client Token associated with the map control that this functionality was available. 

Thanks in advance for any help you can give me.