Skip to content

Instantly share code, notes, and snippets.

@jpukg
Forked from sunieldalal/Base64Example.java
Created October 6, 2016 21:27
Show Gist options
  • Save jpukg/6cd577adb7dbaaa186ecd77d60384175 to your computer and use it in GitHub Desktop.
Save jpukg/6cd577adb7dbaaa186ecd77d60384175 to your computer and use it in GitHub Desktop.
Base64 username/pasword example
//Reference: http://ostermiller.org/utils/Base64.html
URL url = new URL("http://....");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty(
"Authorization",
"Basic " + Base64.encode(
username + ":" + password
)
);
InputStream in = connection.getInputStream();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment