---
title: Basic authentication code samples
description: Samples of basic authentication code for several programming languages and versions.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/web-services/r\_BasicAuthenticationExamples.html
release: australia
product: Web Services
classification: web-services
topic_type: reference
last_updated: "2026-03-12"
reading_time_minutes: 1
breadcrumb: [SOAP web service, Inbound, Web services, API implementation, API implementation and reference]
---
# Basic authentication code samples
Samples of basic authentication code for several programming languages and versions.
## Perl and the SOAP::Lite libraries
To supply basic authentication when using Perl and the SOAP::Lite libraries, you can implement the following function:
```
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return 'user_name' => 'password';
}
```
## C\# .NET VS 2005 or older
When using C\# .NET VS 2005 or older, you can take advantage of the Credentials object. For example:
```
System.Net.ICredentials cred = new System.Net.NetworkCredential("user_name", "password");
service.ServiceNow proxy = new service.ServiceNow();
service.get getService = newservice.get();
service.getResponse getServiceResponse = new service.getResponse();
try
{
proxy.Credentials = cred;
getService.sys_id = "bf522c350a0a140701972dbf876f1610";
getServiceResponse = proxy.get(getService);
catch (Exception ex) { }
```
## C\# .NET VS 2008
When using C\# .NET VS 2008, you can take advantage of the ClientCredentials object. For example:
```
Demo_Incident.ServiceNowSoapClient client = new Test08WebService.Demo_Incident.ServiceNowSoapClient();
client.ClientCredentials.UserName.UserName = "admin";
client.ClientCredentials.UserName.Password = "admin";
```
Then in your `app.config` file look for the following and change "None" to "Basic":
```
type Status report
message
description This request requires HTTP authentication ().