Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Commit e4ec3db

Browse files
committed
Merge pull request #28 from brettgerry/update-headers
Update headers for requests and fix capability token exp timestamp
2 parents c4d3aea + 0699477 commit e4ec3db

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/classes/TwilioCapability.cls

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ global class TwilioCapability {
119119
* @return the newly generated token that is valid for 3600 seconds
120120
*/
121121
global String generateToken() {
122-
return generateToken(System.currentTimeMillis() + 3600);
122+
return generateToken(3600);
123123
}
124124

125125
/**
@@ -137,12 +137,11 @@ global class TwilioCapability {
137137
buildOutgoingScope();
138138
Map<String, Object> payload = new Map<String, Object>();
139139
payload.put('iss', this.accountSid);
140-
payload.put('exp', String.valueOf(System.currentTimeMillis() + ttl));
140+
payload.put('exp', String.valueOf(System.currentTimeMillis()/1000 + ttl));
141141
payload.put('scope', join(this.scopes, ' '));
142142
return jwtEncode(payload, this.authToken);
143143
}
144144

145-
146145
/* PRIVATE METHODS */
147146

148147
/**
@@ -326,4 +325,4 @@ global class TwilioCapability {
326325
}
327326

328327
private class TestOnlyException extends Exception {}
329-
}
328+
}

src/classes/TwilioRestClient.cls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
2828
public class TwilioRestClient {
2929

3030
/** The Constant VERSION. */
31-
private static final String VERSION = '3.0';
31+
private static final String VERSION = '3.1.0';
3232

3333
/** The endpoint. */
3434
private String endpoint = 'https://api.twilio.com';
@@ -524,8 +524,9 @@ public class TwilioRestClient {
524524
HttpRequest request = buildMethod(method, path, params);
525525

526526
request.setHeader('X-Twilio-Client', 'salesforce-' + VERSION);
527-
request.setHeader('User-Agent', 'twilio-salesforce-' + VERSION);
527+
request.setHeader('User-Agent', 'twilio-salesforce/' + VERSION);
528528
request.setHeader('Accept', 'application/json');
529+
request.setHeader('Accept-Charset', 'utf-8');
529530

530531
request.setHeader('Authorization',
531532
'Basic '+EncodingUtil.base64Encode(Blob.valueOf(this.accountSid + ':' + this.authToken)));

src/classes/Twilio_TestRest.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private class Twilio_TestRest {
2929
final static String authToken = '12345678901234567890123456789012';
3030

3131
static testMethod void testTwilioRestResponse() {
32-
String url = 'http://api.twilio.com';
32+
String url = 'https://api.twilio.com';
3333
String queryString = 'a=1&b=2';
3434
String responseText = 'This is a test';
3535
TwilioRestResponse response = new TwilioRestResponse(url+'?'+queryString,responseText,200);

0 commit comments

Comments
 (0)