On Thu, 22 Feb 2018 15:45:23 GMT, John More wrote:

Has anyone used JWTD with google calendar API. I have tried fastJWT with no luck and I am having trouble understanding how to use JWTD.

An example would go a long way to help.


I got it to work with the following code but I have no idea what libraries it is using.

string theKey = "EOS
As issued from google.
-----END PRIVATE KEY-----";
void main()
	struct Claims
	   string iss;
	   string scope_;
	   string aud;
	   long exp;
	   long iat;
           string sub;

	Claims theClaims;
	theClaims.iss = "hasu-scheduling@hasu-calendar.iam.gserviceaccount.com";
        theClaims.scope_ = "https://www.googleapis.com/auth/calendar";
        theClaims.aud = "https://www.googleapis.com/oauth2/v4/token";
        theClaims.exp = core.stdc.time.time(null) + 3600;
        theClaims.iat = core.stdc.time.time(null);
        theClaims.sub = "";

        JWTAlgorithm algo = JWTAlgorithm.RS256;
        auto header_fields = JSONValue();
        auto payload = parseJSON(serializeToJsonString(theClaims));
        writeln(encode(payload, theKey, JWTAlgorithm.RS256, header_fields));
        // copy the result from the console and past in POSTMAN
        // will move to web server next