ebay-api 9.0.0 → 9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -116,7 +116,7 @@ class XMLRequest {
116
116
  log('error', error);
117
117
  if (error.response?.data) {
118
118
  const json = this.toJSON(error.response.data);
119
- checkEBayTraditionalResponse(error.response, json);
119
+ checkEBayTraditionalResponse(error.response, json[this.callName + 'Response']);
120
120
  }
121
121
  throw error;
122
122
  }
@@ -67,13 +67,13 @@ class OAuth2 extends Base {
67
67
  throw new Error('Missing Cert Id (Client Secret)');
68
68
  }
69
69
  try {
70
- const response = await this.req.post(this.identityEndpoint, {
70
+ const response = await this.req.postForm(this.identityEndpoint, {
71
71
  scope: this.scope.join(' '),
72
72
  grant_type: 'client_credentials',
73
73
  }, {
74
- headers: {
75
- 'Content-Type': 'application/x-www-form-urlencoded',
76
- 'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
74
+ auth: {
75
+ username: this.config.appId,
76
+ password: this.config.certId
77
77
  }
78
78
  });
79
79
  return response.data;
@@ -105,14 +105,14 @@ class OAuth2 extends Base {
105
105
  throw new Error('Missing Cert Id (Client Secret)');
106
106
  }
107
107
  try {
108
- const response = await this.req.post(this.identityEndpoint, {
108
+ const response = await this.req.postForm(this.identityEndpoint, {
109
109
  grant_type: 'authorization_code',
110
110
  code,
111
111
  redirect_uri: ruName
112
112
  }, {
113
- headers: {
114
- 'Content-Type': 'application/x-www-form-urlencoded',
115
- 'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
113
+ auth: {
114
+ username: this.config.appId,
115
+ password: this.config.certId
116
116
  }
117
117
  });
118
118
  const token = response.data;
@@ -133,14 +133,14 @@ class OAuth2 extends Base {
133
133
  throw new Error('Failed to refresh the user access token. Token or refresh_token is not set.');
134
134
  }
135
135
  try {
136
- const response = await this.req.post(this.identityEndpoint, {
136
+ const response = await this.req.postForm(this.identityEndpoint, {
137
137
  grant_type: 'refresh_token',
138
138
  refresh_token: this._authToken.refresh_token,
139
139
  scope: this.scope.join(' ')
140
140
  }, {
141
- headers: {
142
- 'Content-Type': 'application/x-www-form-urlencoded',
143
- 'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
141
+ auth: {
142
+ username: this.config.appId,
143
+ password: this.config.certId
144
144
  }
145
145
  });
146
146
  const token = response.data;