Skip to content

Commit

Permalink
Remove unused tokenservice endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
plutov committed Aug 30, 2024
1 parent 9451bef commit c9c1a38
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.23"
- name: Install dependencies
run: go get .
- name: Install linters
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.23"
- name: Install dependencies
run: go get .
- name: Run Tests
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[Docs](https://pkg.go.dev/github.com/plutov/paypal)

<p>
<a href="https://github.com/plutov/paypal/releases"><img src="https://img.shields.io/github/release/plutov/paypal.svg" alt="Latest Release"></a>
<a href="https://pkg.go.dev/github.com/plutov/paypal?tab=doc"><img src="https://godoc.org/github.com/golang/gddo?status.svg" alt="GoDoc"></a>
</p>

# Go client for PayPal REST API

## Paypal REST API Docs
Expand Down Expand Up @@ -294,10 +299,10 @@ invoice, err := c.GetInvoiceDetails(ctx, "INV2-XFXV-YW42-ZANU-4F33")
- Check that tests are passing
- Create PR

Current contributors:
Main contributors:

- [Roopak Venkatakrishnan](https://github.com/roopakv)
- [Alex Pliutau](https://github.com/plutov)
- [Roopak Venkatakrishnan](https://github.com/roopakv)

## Tests

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/plutov/paypal/v4

go 1.21
go 1.23

require github.com/stretchr/testify v1.9.0

Expand Down
49 changes: 0 additions & 49 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,10 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
)

// GrantNewAccessTokenFromAuthCode - Use this call to grant a new access token, using the previously obtained authorization code.
// Endpoint: POST /v1/identity/openidconnect/tokenservice
func (c *Client) GrantNewAccessTokenFromAuthCode(ctx context.Context, code, redirectURI string) (*TokenResponse, error) {
token := &TokenResponse{}

q := url.Values{}
q.Set("grant_type", "authorization_code")
q.Set("code", code)
q.Set("redirect_uri", redirectURI)

req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/identity/openidconnect/tokenservice"), strings.NewReader(q.Encode()))
if err != nil {
return token, err
}

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

if err = c.SendWithBasicAuth(req, token); err != nil {
return token, err
}

return token, nil
}

// GrantNewAccessTokenFromRefreshToken - Use this call to grant a new access token, using a refresh token.
// Endpoint: POST /v1/identity/openidconnect/tokenservice
func (c *Client) GrantNewAccessTokenFromRefreshToken(ctx context.Context, refreshToken string) (*TokenResponse, error) {
type request struct {
GrantType string `json:"grant_type"`
RefreshToken string `json:"refresh_token"`
}

token := &TokenResponse{}

req, err := c.NewRequest(ctx, "POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/identity/openidconnect/tokenservice"), request{GrantType: "refresh_token", RefreshToken: refreshToken})
if err != nil {
return token, err
}

if err = c.SendWithAuth(req, token); err != nil {
return token, err
}

return token, nil
}

// GetUserInfo - Use this call to retrieve user profile attributes.
// Endpoint: GET /v1/identity/openidconnect/userinfo/?schema=<Schema>
// Pass the schema that is used to return as per openidconnect protocol. The only supported schema value is openid.
func (c *Client) GetUserInfo(ctx context.Context, schema string) (*UserInfo, error) {
u := &UserInfo{}

Expand Down
4 changes: 2 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

const (
// APIBaseSandBox points to the sandbox (for testing) version of the API
APIBaseSandBox = "https://api.sandbox.paypal.com"
APIBaseSandBox = "https://api-m.sandbox.paypal.com"

// APIBaseLive points to the live version of the API
APIBaseLive = "https://api.paypal.com"
APIBaseLive = "https://api-m.paypal.com"

// RequestNewTokenBeforeExpiresIn is used by SendWithAuth and try to get new Token when it's about to expire
RequestNewTokenBeforeExpiresIn = time.Duration(60) * time.Second
Expand Down

0 comments on commit c9c1a38

Please sign in to comment.