Skip to content

Commit c7f03eb

Browse files
authored
Merge pull request #13 from EikaGruppen/only-scope-param-if-set
fix: only send scope param if set
2 parents 899bfce + 7a60a15 commit c7f03eb

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

authorize.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func authorizeUrl(opts Options, port int) (request authorizeRequest, err error)
4949
"code_challenge": {codeChallange},
5050
"code_challenge_method": {"S256"},
5151
"state": {request.state},
52-
"scope": {strings.Join(opts.Scopes, " ")},
52+
}
53+
if len(opts.Scopes) > 0 {
54+
q.Add("scope", strings.Join(opts.Scopes, " "))
5355
}
5456

5557
for k, v := range opts.AuthorizationExtParams {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/EikaGruppen/go-oauth-cli-client
22

3-
go 1.20
3+
go 1.24

oauth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net"
99
"net/http"
1010
"net/url"
@@ -71,7 +71,7 @@ func getAuthorizationCode(opts Options, code string, authorizeRequest authorizeR
7171
}
7272
defer response.Body.Close()
7373

74-
body, err := ioutil.ReadAll(response.Body)
74+
body, err := io.ReadAll(response.Body)
7575
if err != nil {
7676
return nil, err
7777
}

refresh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package oauth
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/url"
99
)
@@ -21,7 +21,7 @@ func Refresh(opts Options, refreshToken string) (*TokenResponse, error) {
2121
}
2222
defer response.Body.Close()
2323

24-
body, err := ioutil.ReadAll(response.Body)
24+
body, err := io.ReadAll(response.Body)
2525
if err != nil {
2626
return nil, err
2727
}

revoke.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package oauth
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/url"
99
)
@@ -37,7 +37,7 @@ func Revoke(opts Options, tokenType TokenType, token string) error {
3737
}
3838
defer response.Body.Close()
3939

40-
body, err := ioutil.ReadAll(response.Body)
40+
body, err := io.ReadAll(response.Body)
4141
if err != nil {
4242
return err
4343
}

0 commit comments

Comments
 (0)