Skip to content

Commit 258c555

Browse files
Merge pull request #38 from RakeshMohanMSFT/patch-2
Update AccountController.cs
2 parents 5ce886e + fcbcdb9 commit 258c555

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

delegation/ContosoWebApplication/ContosoWebApplication/Controllers/AccountController.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,30 @@ public async Task<ActionResult> Delegate()
476476
{
477477
client.BaseAddress = new Uri(ApimRestHost);
478478
client.DefaultRequestHeaders.Add("Authorization", ApimRestAuthHeader());
479-
480-
HttpResponseMessage response = await client.PostAsync("users/" + User.Identity.GetUserId() + "/generateSsoUrl?api-version=" + ApimRestApiVersion, this.GetContent(""));
479+
480+
var ApimUser = new
481+
{
482+
keyType = "primary",
483+
expiry = ApimRestExpiry
484+
};
485+
486+
var ApimUserJson = SerializeToJson(ApimUser);
487+
488+
//We are deprecating generateSsoUrl and henceforth will use token to get primary key
489+
HttpResponseMessage response = await client.PostAsync("users/" + User.Identity.GetUserId() + "/token?api-version=" + ApimRestApiVersion, this.GetContent(ApimUserJson));
481490
if (response.IsSuccessStatusCode)
482491
{
483492
//We got an SSO token - redirect
484493
HttpContent receiveStream = response.Content;
485494
var SsoUrlJson = await receiveStream.ReadAsStringAsync();
486495
SsoUrl su = DeserializeToJson<SsoUrl>(SsoUrlJson);
487496

497+
//We need to encode the primary key before passing it to the sso url.
498+
string url = string.Format("{0}/signin-sso?token={1}", developerPortalUrl, HttpUtility.UrlEncode(su.value));
488499
//Currently this is returing the old developer portal url, if you want to implement it with new developer portal please use .Replace("portal","developer") or similar to get it to work.
489500
//We have work item for this and should be fixed soon.
490501
//return Redirect(su.value.Replace(".portal.", ".developer."));
491-
return Redirect(su.value);
502+
return Redirect(url);
492503
}
493504
else
494505
{

0 commit comments

Comments
 (0)