Ejemplo n.º 1
0
 private void SetStandardHeaders(WebRequest request, string username = null, string password = null)
 {
     request.Headers[HttpRequestHeader.Authorization]  = string.Format("Bearer {0}", _oauth.Maybe(_ => _.AccessToken, string.Empty));
     request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip";
     request.Headers["x-myobapi-key"]     = _configuration.ClientId;
     request.Headers["x-myobapi-version"] = "v2";
     request.Headers["x-myobapi-cftoken"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username.Maybe(_ => _, string.Empty), password.Maybe(_ => _, string.Empty))));
 }
Ejemplo n.º 2
0
 public void SetStandardHeaders(WebRequest request, IApiConfiguration configuration, ICompanyFileCredentials credentials, OAuthTokens oauth = null)
 {
     request.Headers[HttpRequestHeader.Authorization]  = string.Format("Bearer {0}", oauth.Maybe(_ => _.AccessToken, string.Empty));
     request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip";
     request.Headers["x-myobapi-key"]     = configuration.ClientId;
     request.Headers["x-myobapi-version"] = "v2";
     request.Headers["x-myobapi-cftoken"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}",
                                                                                                        credentials.Maybe(_ => _.Username).Maybe(_ => _, string.Empty), credentials.Maybe(_ => _.Password).Maybe(_ => _, string.Empty))));
 }