ShipStation uses basic authentication to provide a username and password to your AuctionWorx site. Store the login information in the web.config file by adding key/value pairs into the <appSettings></appSettings>
node. (The ShipStation credential configuration is dealt with in Creating a Custom Store) :
<add key="ShipStationUsername" value="SSAWEdeploy123"/> <add key="ShipStationPassword" value="33xRrab1904X"/>
ShipStation submits a Basic HTTP authentication header when it requests order data. The isVerifiedUser() routine parses the HTTP authentication header, decodes the credentials, and validates the username and password against the credentials stored in the web.config file.
protected bool isVerifiedUser(string authHeader) { if (!authHeader.StartsWith("Basic")) { LogManager.WriteLog("ShipStation failed authorization header", "ShipStation Login", "ShipStation"); return false; } string encodedUsernamePassword = authHeader.Substring ("Basic ".Length).Trim(); Encoding encoding = Encoding.GetEncoding("iso-8859-1"); string usernamePassword = string.Empty; int separatorIndex = 0; try { usernamePassword = encoding.GetString (Convert.FromBase64String(encodedUsernamePassword)); separatorIndex = usernamePassword.IndexOf(':'); } catch (Exception exc) { LogManager.WriteLog(exc.Message, "ShipStation Error", "ShipStation"); return false; } var username = usernamePassword.Substring(0, separatorIndex); var password = usernamePassword.Substring(separatorIndex + 1); string ShipStationUsername = ConfigurationManager. AppSettings["ShipStationUsername"]; string ShipStationPassword = ConfigurationManager. AppSettings["ShipStationPassword"]; if (password == ShipStationPassword && username == ShipStationUsername) { LogManager.WriteLog("ShipStation successful login", "ShipStation Login", "ShipStation"); return true; } LogManager.WriteLog("ShipStation failed login", "ShipStation Login", "ShipStation"); return false; }
Copyright © 2002-2022. RainWorx Software. All rights reserved.