@@ -25,8 +25,7 @@ import (
2525// Client provides convenient methods for common operations.
2626// To build others, see the [GraphQLQuery] and [GraphQLMutation] methods.
2727type Client struct {
28- user string
29- passwd string
28+ token string
3029}
3130
3231// Dial returns a Client authenticating as user.
@@ -40,17 +39,16 @@ type Client struct {
4039//
4140// machine api.github.com login ken password ghp_123456789abcdef123456789abcdef12345
4241func Dial (user string ) (* Client , error ) {
43- user , passwd , err := netrcAuth ("api.github.com" , user )
42+ _ , passwd , err := netrcAuth ("api.github.com" , user )
4443 if err != nil {
4544 return nil , err
4645 }
47- return & Client {user : user , passwd : passwd }, nil
46+ return & Client {token : passwd }, nil
4847}
4948
50- // NewClient returns a new client authenticating as the given GitHub user
51- // with the given GitHub personal access token (of the form "ghp_....").
52- func NewClient (user , token string ) * Client {
53- return & Client {user : user , passwd : token }
49+ // NewClient returns a new client using the given GitHub personal access token (of the form "ghp_....").
50+ func NewClient (token string ) * Client {
51+ return & Client {token : token }
5452}
5553
5654// A Vars is a binding of GraphQL variables to JSON-able values (usually strings).
@@ -131,8 +129,8 @@ Retry:
131129 if err != nil {
132130 return err
133131 }
134- if c .user != "" {
135- req .SetBasicAuth ( c . user , c . passwd )
132+ if c .token != "" {
133+ req .Header . Set ( "Authorization" , "Bearer " + c . token )
136134 }
137135
138136 previews := []string {
0 commit comments