Created
          November 20, 2015 09:25 
        
      - 
      
- 
        Save lujiacn/bd6a4e409560a175c96b to your computer and use it in GitHub Desktop. 
    go client basic auth
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ## from https://answers.callfire.com/hc/en-us/articles/205407787-Authentication | |
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| ) | |
| func main() { | |
| client := &http.Client{} | |
| req, err := http.NewRequest("GET", "https://www.callfire.com/api/1.1/rest/contact", nil) | |
| req.SetBasicAuth("<username>", "<password>") | |
| resp, err := client.Do(req) | |
| if err != nil { | |
| fmt.Printf("Error : %s", err) | |
| } | |
| // Retrieve the body of the response | |
| body, err := ioutil.ReadAll(resp.Body) | |
| resp.Body.Close() | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| // Dump the response | |
| fmt.Printf("%s", body) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment