abouttreesummaryrefslogcommitdiff
path: root/examples/Login.c
diff options
context:
space:
mode:
authorPatrick2023-05-20 00:02:34 +0200
committerPatrick2023-05-20 00:02:34 +0200
commit71b13552379398dafcbc8fa8347d119a8984f448 (patch)
tree5c43d7ec7e0e87c6fb4852c77c3668880bad7d2f /examples/Login.c
parent7cba6b3cdbd3b82ec9092ce9bda8ec20739096cb (diff)
downloadmatrix_esp_thesis-71b13552379398dafcbc8fa8347d119a8984f448.tar.gz
matrix_esp_thesis-71b13552379398dafcbc8fa8347d119a8984f448.zip
get Login example working with CURL
Diffstat (limited to 'examples/Login.c')
-rw-r--r--examples/Login.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/examples/Login.c b/examples/Login.c
index 5f07e87..69ac3a1 100644
--- a/examples/Login.c
+++ b/examples/Login.c
@@ -1,27 +1,34 @@
#include <stdio.h>
#include <matrix.h>
+#include <curl/curl.h>
-#define SERVER FixedBuf("matrix.org")
-#define USERNAME FixedBuf("@pscho:matrix.org")
-#define PASSWORD FixedBuf("abcde")
+#define SERVER "https://matrix.org"
+#define USERNAME "pscho"
+#define PASSWORD "Wc23EbmB9G3faMq"
+#define DISPLAYNAME "MatrixClient"
int
-main(
- int argc,
- char **argv)
+main()
{
MatrixClient client;
- MatrixClientInit(&client, SERVER);
+ MatrixClientInit(&client, SERVER, strlen(SERVER));
+
+ curl_global_init(CURL_GLOBAL_DEFAULT);
+ client.httpUserData = (void *)curl_easy_init();
MatrixClientLoginPassword(&client,
- USERNAME,
- PASSWORD);
+ USERNAME, strlen(USERNAME),
+ PASSWORD, strlen(PASSWORD),
+ DISPLAYNAME, strlen(DISPLAYNAME));
- static char accessTokenCharBuffer[ACCESS_TOKEN_LEN];
- FixedBuffer accessTokenBuffer = { accessTokenCharBuffer, ACCESS_TOKEN_LEN, 0 };
- MatrixClientGetAccessToken(&client, &accessTokenBuffer);
- printf("Access Token: %.*s\n", accessTokenBuffer.len, (char *)accessTokenBuffer.ptr);
+ printf("Access Token: %.*s\n", client.accessTokenLen, client.accessTokenBuffer);
+ printf("Device ID: %.*s\n", client.deviceIdLen, client.deviceIdBuffer);
+ printf("Expires in (ms): %.*s\n", client.expireMsLen, client.expireMsBuffer);
+ printf("Refresh Token: %.*s\n", client.refreshTokenLen, client.refreshTokenBuffer);
+
+ curl_easy_cleanup((CURL *)client.httpUserData);
+ curl_global_cleanup();
return 0;
} \ No newline at end of file