mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-07-13 01:00:23 +02:00
Update docs to reflect JIRA's guidance about authentication
This commit is contained in:
33
README.md
33
README.md
@ -89,13 +89,13 @@ For convenience, capability for basic and cookie-based authentication is include
|
|||||||
|
|
||||||
#### Basic auth example
|
#### Basic auth example
|
||||||
|
|
||||||
A more thorough, [runnable example](examples/basicauth/main.go) is provided in the examples directory.
|
A more thorough, [runnable example](examples/basicauth/main.go) is provided in the examples directory. **It's worth noting that using passwords in basic auth is now deprecated and will be removed.** Jira gives you the ability to [create tokens now.](https://confluence.atlassian.com/cloud/api-tokens-938839638.html)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
tp := jira.BasicAuthTransport{
|
tp := jira.BasicAuthTransport{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Password: "password",
|
Password: "token",
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := jira.NewClient(tp.Client(), "https://my.jira.com")
|
client, err := jira.NewClient(tp.Client(), "https://my.jira.com")
|
||||||
@ -106,25 +106,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Authenticate with session cookie
|
#### Authenticate with session cookie [DEPRECATED]
|
||||||
|
|
||||||
A more thorough, [runnable example](examples/cookieauth/main.go) is provided in the examples directory.
|
JIRA [deprecated this authentication method.](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/) It's not longer available for use.
|
||||||
|
|
||||||
Note: The `AuthURL` is almost always going to have the path `/rest/auth/1/session`
|
|
||||||
|
|
||||||
```go
|
|
||||||
tp := jira.CookieAuthTransport{
|
|
||||||
Username: "username",
|
|
||||||
Password: "password",
|
|
||||||
AuthURL: "https://my.jira.com/rest/auth/1/session",
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := jira.NewClient(tp.Client(), "https://my.jira.com")
|
|
||||||
u, _, err := client.User.Get("admin")
|
|
||||||
|
|
||||||
fmt.Printf("\nEmail: %v\nSuccess!\n", u.EmailAddress)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Authenticate with OAuth
|
#### Authenticate with OAuth
|
||||||
|
|
||||||
@ -146,10 +131,9 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
base := "https://my.jira.com"
|
base := "https://my.jira.com"
|
||||||
tp := jira.CookieAuthTransport{
|
tp := jira.BasicAuthTransport{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Password: "password",
|
Password: "token",
|
||||||
AuthURL: fmt.Sprintf("%s/rest/auth/1/session", base),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jiraClient, err := jira.NewClient(tp.Client(), base)
|
jiraClient, err := jira.NewClient(tp.Client(), base)
|
||||||
@ -200,10 +184,9 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
base := "https://my.jira.com"
|
base := "https://my.jira.com"
|
||||||
tp := jira.CookieAuthTransport{
|
tp := jira.BasicAuthTransport{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Password: "password",
|
Password: "token",
|
||||||
AuthURL: fmt.Sprintf("%s/rest/auth/1/session", base),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jiraClient, err := jira.NewClient(tp.Client(), base)
|
jiraClient, err := jira.NewClient(tp.Client(), base)
|
||||||
|
Reference in New Issue
Block a user