Connect
Request Token
Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Events
- Meters
- Benefits
- Customer Meters
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Customer Events
- Billing Events
- Organization Events
OAuth 2.0 API
Connect
Request Token
Request an access token using a valid grant.
POST
/
v1
/
oauth2
/
token
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.Oauth2.Token(ctx, operations.CreateOauth2RequestTokenRequestBodyAuthorizationCodeTokenRequest(
components.AuthorizationCodeTokenRequest{
ClientID: "<id>",
ClientSecret: "<value>",
Code: "<value>",
RedirectURI: "https://talkative-barracks.com",
},
))
if err != nil {
log.Fatal(err)
}
if res.TokenResponse != nil {
// handle response
}
}
{
"access_token": "<string>",
"token_type": "<string>",
"expires_in": 123,
"refresh_token": "<string>",
"scope": "<string>",
"id_token": "<string>"
}
Body
application/x-www-form-urlencoded
Response
200 - application/json
Successful Response
The response is of type object
.
Was this page helpful?
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.Oauth2.Token(ctx, operations.CreateOauth2RequestTokenRequestBodyAuthorizationCodeTokenRequest(
components.AuthorizationCodeTokenRequest{
ClientID: "<id>",
ClientSecret: "<value>",
Code: "<value>",
RedirectURI: "https://talkative-barracks.com",
},
))
if err != nil {
log.Fatal(err)
}
if res.TokenResponse != nil {
// handle response
}
}
{
"access_token": "<string>",
"token_type": "<string>",
"expires_in": 123,
"refresh_token": "<string>",
"scope": "<string>",
"id_token": "<string>"
}