mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-02-13 13:48:28 +02:00
Update README to include new information for basic auth
This commit is contained in:
parent
555db9e15b
commit
dce2b8ab5d
36
README.md
36
README.md
@ -80,35 +80,29 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Authenticate with jira
|
### Authentication
|
||||||
|
|
||||||
Some actions require an authenticated user.
|
The `go-jira` library does not handle most authentication directly. Instead, authentication should be handled within
|
||||||
|
an `http.Client`. That client can then be passed into the `NewClient` function when creating a jira client.
|
||||||
|
|
||||||
#### Authenticate with basic auth
|
For convenience, capability for basic and cookie-based authentication is included in the main library.
|
||||||
|
|
||||||
Here is an example with basic auth authentication.
|
#### Basic auth example
|
||||||
|
|
||||||
|
A more thorough, [runnable example](examples/basicauth/main.go) is provided in the examples directory.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/andygrunwald/go-jira"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
jiraClient, err := jira.NewClient(nil, "https://your.jira-instance.com/")
|
tp := jira.BasicAuthTransport{
|
||||||
if err != nil {
|
Username: strings.TrimSpace(username),
|
||||||
panic(err)
|
Password: strings.TrimSpace(password),
|
||||||
}
|
|
||||||
jiraClient.Authentication.SetBasicAuth("username", "password")
|
|
||||||
|
|
||||||
issue, _, err := jiraClient.Issue.Get("SYS-5156", nil)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
|
client, err := jira.NewClient(tp.Client(), "https://my.jira.com")
|
||||||
|
|
||||||
|
u, _, err := client.User.Get("some_user")
|
||||||
|
|
||||||
|
fmt.Printf("\nEmail: %v\nSuccess!\n", u.EmailAddress)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user