@@ -41,10 +41,10 @@ type JWTAuthConfig struct {
4141// NewJWTAuth creates a new OAuth 2.0 JWT authentication provider
4242func NewJWTAuth (config JWTAuthConfig ) * JWTAuth {
4343 if config .Audience == "" {
44- config .Audience = "appstoreconnect-v1"
44+ config .Audience = DefaultJWTAudience
4545 }
4646 if config .Scope == "" {
47- config .Scope = "business.api"
47+ config .Scope = ScopeBusinessAPI
4848 }
4949
5050 return & JWTAuth {
@@ -96,7 +96,6 @@ func (j *JWTAuth) getAccessToken() (string, error) {
9696 return "" , fmt .Errorf ("failed to exchange for access token: %w" , err )
9797 }
9898
99- // Store the token
10099 j .accessToken = tokenResp .AccessToken
101100 j .tokenExpiry = time .Now ().Add (time .Duration (tokenResp .ExpiresIn ) * time .Second )
102101
@@ -111,7 +110,7 @@ func (j *JWTAuth) generateClientAssertion() (string, error) {
111110 claims := jwt.MapClaims {
112111 "iss" : j .issuerID , // team_id (issuer)
113112 "sub" : j .issuerID , // client_id (subject) - same as issuer for Apple
114- "aud" : "https://account.apple.com/auth/oauth2/v2/token" , // OAuth 2.0 token endpoint
113+ "aud" : DefaultOAuthTokenEndpoint , // OAuth 2.0 token endpoint
115114 "iat" : now .Unix (),
116115 "exp" : now .Add (180 * 24 * time .Hour ).Unix (), // Max 180 days as per Apple docs
117116 "jti" : fmt .Sprintf ("%d" , now .UnixNano ()), // Unique identifier
@@ -161,7 +160,7 @@ func (j *JWTAuth) exchangeForAccessToken(clientAssertion string) (*TokenResponse
161160 SetHeader ("Content-Type" , "application/x-www-form-urlencoded" ).
162161 SetHeader ("Host" , "account.apple.com" ).
163162 SetResult (& tokenResp ).
164- Post ("https://account.apple.com/auth/oauth2/v2/token" )
163+ Post (DefaultOAuthTokenEndpoint )
165164
166165 if err != nil {
167166 return nil , fmt .Errorf ("failed to make token request: %w" , err )
@@ -208,4 +207,3 @@ func (a *APIKeyAuth) ApplyAuth(req *resty.Request) error {
208207 }
209208 return nil
210209}
211-
0 commit comments