/// <summary> /// Builds the Token payload /// </summary> /// <returns>TokenRequest instance</returns> public TokenRequest build() { string serializeState = TokenRequestState.Create( csrfToken == null ? "" : Util.HashString(csrfToken), oauthState ?? "").Serialize(); requestPayload.CallbackState = serializeState; return(new TokenRequest( requestPayload, requestOptions)); }
/// <summary> /// Generates a Token request URL from a request ID, an original state and a CSRF token. /// </summary> /// <param name="requestId">the request id</param> /// <param name="state">the state</param> /// <param name="csrfToken">the csrf token</param> /// <returns>the token request url</returns> public Task <string> GenerateTokenRequestUrl( string requestId, string state = "", string csrfToken = "") { var csrfTokenHash = Util.HashString(csrfToken); var tokenRequestState = TokenRequestState.Create(csrfTokenHash, state); return(Task.FromResult(string.Format( TOKEN_REQUEST_TEMPLATE, tokenCluster.WebAppUrl, requestId, WebUtility.UrlEncode(tokenRequestState.Serialize())))); }