140 size_t inBytes, outBytes;
142 char *key, *outData, inData[1024];
146 if (!strncmp(b64data,
"Bearer%20", 9)) b64data += 9;
152 if (!(dot = index(b64data,
'.')))
return false;
157 inBytes = dot - b64data;
158 if (inBytes >= (
int)
sizeof(inData))
return false;
159 memcpy(inData, b64data, inBytes);
164 outBytes = DecodeBytesNeeded(inBytes);
165 outData = (
char *)alloca(outBytes);
169 if (DecodeUrl(inData, inBytes, outData, outBytes))
return false;
174 if (outBytes <= 0 || *outData !=
'{' || outData[outBytes-1] !=
'}')
179 if (!(key = strstr(outData,
"\"typ\"")))
return false;
184 while(*key ==
' ') key++;
185 if (*key !=
':')
return false;
190 while(*key ==
' ') key++;
191 return strncmp(key,
"\"JWT\"", 5) == 0;