I'm creating a program for oauth2 for ttlock and i have problem reading out a value from "expires_in".
Here is the replay from the request:
{"access_token":"815ef380f7345a76357026c69a71c1ba" ,"refresh_token":"b09efe6945ergd762a5a5a1eaa4c1aba ","uid":7488719,"openid":1785435683,"scope":"u ser, key,room","token_type":"Bearer","expires_in":2779073}
// Extracting refresh_token
char* refresh_token = strstrskip(buffer, ""refresh_token":"");
int pos_B = strfind(refresh_token, """, 0);
refresh_token[pos_B] = 0;
setoutputtext(1, refresh_token);
// Extracting access_token
char* access_token = strstrskip(buffer, ""access_token":"");
int pos_A = strfind(access_token, """, 0);
access_token[pos_A] = 0;
setoutputtext(0, access_token);
// Extracting expires_in
char* expires_in_start = strstrskip(buffer, ""expires_in":");
if (expires_in_start != NULL) {
expires_in_start += strlen(""expires_in":");
double expires = atof(expires_in_start);
printf("Expires in seconds: %f\n", expires);
int expires_int = (int)expires;
setoutput(0, expires_int);
Br eirik
Kommentar