Groovy web console

subscribe to the feed Subscribe
to this

Twitter Groovy Basic Auth

Published 1 decade ago by with tags twitter groovy basic authentication
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def addr = ""
//NOTE: Obviously, set the username and password to your values
def authString = "username:password".getBytes().encodeBase64().toString()
def conn = addr.toURL().openConnection()
conn.setRequestProperty("Authorization", "Basic ${authString}")
if(conn.responseCode == 200){
  def feed = new XmlSlurper().parseText(conn.content.text)
    println entry.title
    println "-"*20
  println "Something bad happened."
  println "${conn.responseCode}: ${conn.responseMessage}"