Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The token, which I sent to the server, had the wrong format. The above token is in a json format and contains a 'securityToken', which is encoded xml. With <code>HttpUtility.UrlDecode</code> and <code>XMLReader</code> it is possible to retrieve the base64 string. The base64 string of the above token is:</p> <p><code>aHR0cCUzYSUyZiUyZnNjaGVtYXMueG1sc29hcC5vcmclMmZ3cyUyZjIwMDUlMmYwNSUyZmlkZW50aXR5JTJmY2xhaW1zJTJmZW1haWxhZGRyZXNzPXBhdHJpY2suZWNrZXIlNDBnbWFpbC5jb20maHR0cCUzYSUyZiUyZnNjaGVtYXMueG1sc29hcC5vcmclMmZ3cyUyZjIwMDUlMmYwNSUyZmlkZW50aXR5JTJmY2xhaW1zJTJmbmFtZT1QYXRyaWNrK0Vja2VyJmh0dHAlM2ElMmYlMmZzY2hlbWFzLnhtbHNvYXAub3JnJTJmd3MlMmYyMDA1JTJmMDUlMmZpZGVudGl0eSUyZmNsYWltcyUyZm5hbWVpZGVudGlmaWVyPWh0dHBzJTNhJTJmJTJmd3d3Lmdvb2dsZS5jb20lMmZhY2NvdW50cyUyZm84JTJmaWQlM2ZpZCUzZEFJdE9hd2xzM1doNlgwRFJ6d1BsdzU2a1R0WURmLVNNaDZxZFJtQSZodHRwJTNhJTJmJTJmc2NoZW1hcy5taWNyb3NvZnQuY29tJTJmYWNjZXNzY29udHJvbHNlcnZpY2UlMmYyMDEwJTJmMDclMmZjbGFpbXMlMmZpZGVudGl0eXByb3ZpZGVyPUdvb2dsZSZBdWRpZW5jZT1odHRwJTNhJTJmJTJmbG9jYWxob3N0JTNhNzEwMCUyZlNlcnZpY2UlMmZEZWZhdWx0LmFzcHgmRXhwaXJlc09uPTEzMjY5OTk4MjEmSXNzdWVyPWh0dHBzJTNhJTJmJTJmZmhiYXlhenVyZW5zLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQlMmYmSE1BQ1NIQTI1Nj1SUnN3OUJTSlc2ZFJ0MjJyNkNkcjZWZHpyJTJicTF6MHlhV0FMNVdlJTJiJTJmV3owJTNk</code></p> <p>I decoded this string and got my ACS token. This ACS token is now valid and my RESTful WCF service can be used.</p> <p>Code on the server side didn't changed. This is what I've got on the client side:</p> <pre><code>// parse the token from the json string, var token = JsonNotifyRequestSecurityTokenResponse.FromJson(txtReceivedToken.Text); // get the security token and decode it string xmlString = HttpUtility.UrlDecode(token.SecurityTokenString); // get the base64 string an string string64 = ""; using (XmlReader xmlReader = XmlReader.Create(new StringReader(xmlString))) { while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Text) { // find the first text element, which should be the base64 string string64 = xmlReader.Value; break; } } } // decode it string acsToken = base64Decode(string64); // set the header string headerValue = string.Format("WRAP access_token=\"{0}\"", acsToken); client.Headers.Add("Authorization", headerValue); Stream stream = client.OpenRead(@"http://127.0.0.1:81/Service1.svc/users"); StreamReader reader = new StreamReader(stream); String response = reader.ReadToEnd(); </code></pre> <p>The <code>base64Decode</code> method i 'stole' from <a href="http://www.vbforums.com/showthread.php?t=287324" rel="noreferrer">http://www.vbforums.com/showthread.php?t=287324</a>. The <code>JsonNotifyRequestSecurityTokenResponse.FromJson</code> part i got from <a href="http://www.leastprivilege.com/" rel="noreferrer">http://www.leastprivilege.com/</a> , but i think it could be parsed with any available JSON parser.</p> <p>I don't know if it is the best solution, but it works for me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload