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

Commit

Permalink
Merge pull request #28 from brettgerry/update-headers
Browse files Browse the repository at this point in the history
Update headers for requests and fix capability token exp timestamp
  • Loading branch information
brettgerry committed Oct 29, 2013
2 parents c4d3aea + 0699477 commit e4ec3db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/classes/TwilioCapability.cls
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ global class TwilioCapability {
* @return the newly generated token that is valid for 3600 seconds
*/
global String generateToken() {
return generateToken(System.currentTimeMillis() + 3600);
return generateToken(3600);
}

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


/* PRIVATE METHODS */

/**
Expand Down Expand Up @@ -326,4 +325,4 @@ global class TwilioCapability {
}

private class TestOnlyException extends Exception {}
}
}
5 changes: 3 additions & 2 deletions src/classes/TwilioRestClient.cls
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
public class TwilioRestClient {

/** The Constant VERSION. */
private static final String VERSION = '3.0';
private static final String VERSION = '3.1.0';

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

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

request.setHeader('Authorization',
'Basic '+EncodingUtil.base64Encode(Blob.valueOf(this.accountSid + ':' + this.authToken)));
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Twilio_TestRest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private class Twilio_TestRest {
final static String authToken = '12345678901234567890123456789012';

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

0 comments on commit e4ec3db

Please sign in to comment.