in code/PublishToEmbeddedSocial/EmbeddedSocial/EmbeddedSocial.cs [75:97]
private async Task<string> CreateEmbeddedSocialAuth(string aadAuthorization, string userHandle)
{
PostSessionRequest sessionRequest = new PostSessionRequest()
{
InstanceId = "OneBusAway Service",
UserHandle = userHandle
};
HttpOperationResponse<PostSessionResponse> response = await this.client.Sessions.PostSessionWithHttpMessagesAsync(request: sessionRequest, authorization: aadAuthorization);
if (response == null || response.Response == null)
{
throw new Exception("did not get a valid response to POST session");
}
else if (!response.Response.IsSuccessStatusCode)
{
throw new Exception("POST session failed with HTTP code " + response.Response.StatusCode);
}
else if (response.Body == null || string.IsNullOrWhiteSpace(response.Body.SessionToken))
{
throw new Exception("POST session resulted in invalid post session response structure");
}
return "SocialPlus TK=" + response.Body.SessionToken;
}