Set HTTP headers for the Hybrid Web Container to include authentication tokens.
These methods in the Hybrid Web Container template source code show
how to set HTTP headers:
- getHttpHeaders – override this method to set the authentication tokens.
- OnHTTPError – listener called by the communication layer when an HTTP error occurs.
- OnTokenError – listener called by the client engine when Hybrid App token
authentication failure occurs.
- In Visual Studio, open the CustomizationHelper class in the
CustomCode folder.
- Override the getHttpHeaders method and uncomment its contents.
The stub code shows how to add headers and cookies. Simply replace the header and
cookie assignments with your own.
- Refresh the HTTP headers.
It is a good idea to refresh the HTTP headers in the
OnTokenError method , which is called when a
Hybrid App token authentication failure occurs.
Here is a common way to do this:
- Maintain member variables that contain the values for the headers you want to
set.
- Override the GetHttpHeaders method to use the value in
those member variables when it sets the headers.
- In OnTokenError, update the member variables with the new
header values.
- Call UpdateHttpHeaders again.
- If you have custom code to run when an HTTP error occurs, add the code to override
the OnHTTPError method.
Your method is called any time there is an HTTP error. You can use it to inform
the user of errors, or to perform other custom steps in response to particular error
codes.