diff options
| author | 2024-05-31 07:00:13 +0000 | |
|---|---|---|
| committer | 2024-05-31 07:00:13 +0000 | |
| commit | f7baafb41636d53402618da17a51b0bff2a3a8bd (patch) | |
| tree | 81e707e34129d1395ec631f4535ac3d1a3536c75 /mastoapi.c | |
| parent | Updated RELEASE_NOTES. (diff) | |
| parent | Fix login with IceCubes and Mastodon on iOS (diff) | |
| download | snac2-f7baafb41636d53402618da17a51b0bff2a3a8bd.tar.gz snac2-f7baafb41636d53402618da17a51b0bff2a3a8bd.tar.xz snac2-f7baafb41636d53402618da17a51b0bff2a3a8bd.zip | |
Merge pull request 'Fix login issues with Mastodon, IceCube, Toot! on iOS' (#174) from louis77/snac2:apps into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/174
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 19 |
1 files changed, 13 insertions, 6 deletions
| @@ -152,6 +152,7 @@ const char *login_page = "" | |||
| 152 | "<html>\n" | 152 | "<html>\n" |
| 153 | "<head>\n" | 153 | "<head>\n" |
| 154 | "<title>%s OAuth - Snac2</title>\n" | 154 | "<title>%s OAuth - Snac2</title>\n" |
| 155 | "<meta content=\"width=device-width, initial-scale=1, minimum-scale=1, user-scalable=no\" name=\"viewport\">" | ||
| 155 | "<style>:root {color-scheme: light dark}</style>\n" | 156 | "<style>:root {color-scheme: light dark}</style>\n" |
| 156 | "</head>\n" | 157 | "</head>\n" |
| 157 | "<body><h1>%s OAuth identify</h1>\n" | 158 | "<body><h1>%s OAuth identify</h1>\n" |
| @@ -338,11 +339,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 338 | const char *cid = xs_dict_get(args, "client_id"); | 339 | const char *cid = xs_dict_get(args, "client_id"); |
| 339 | const char *csec = xs_dict_get(args, "client_secret"); | 340 | const char *csec = xs_dict_get(args, "client_secret"); |
| 340 | const char *ruri = xs_dict_get(args, "redirect_uri"); | 341 | const char *ruri = xs_dict_get(args, "redirect_uri"); |
| 341 | /* FIXME: this 'scope' parameter is mandatory for the official Mastodon API, | 342 | const char *scope = xs_dict_get(args, "scope"); |
| 342 | but if it's enabled, it makes it crash after some more steps, which | ||
| 343 | is FAR WORSE */ | ||
| 344 | const char *scope = NULL; | ||
| 345 | // scope = xs_dict_get(args, "scope"); | ||
| 346 | 343 | ||
| 347 | /* no client_secret? check if it's inside an authorization header | 344 | /* no client_secret? check if it's inside an authorization header |
| 348 | (AndStatus does it this way) */ | 345 | (AndStatus does it this way) */ |
| @@ -1164,8 +1161,10 @@ void credentials_get(char **body, char **ctype, int *status, snac snac) | |||
| 1164 | acct = xs_dict_append(acct, "url", snac.actor); | 1161 | acct = xs_dict_append(acct, "url", snac.actor); |
| 1165 | acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE)); | 1162 | acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE)); |
| 1166 | acct = xs_dict_append(acct, "bot", xs_dict_get(snac.config, "bot")); | 1163 | acct = xs_dict_append(acct, "bot", xs_dict_get(snac.config, "bot")); |
| 1164 | acct = xs_dict_append(acct, "emojis", xs_list_new()); | ||
| 1167 | 1165 | ||
| 1168 | xs *src = xs_json_loads("{\"privacy\":\"public\"," | 1166 | xs *src = xs_json_loads("{\"privacy\":\"public\", \"language\":\"en\"," |
| 1167 | "\"follow_requests_count\": 0," | ||
| 1169 | "\"sensitive\":false,\"fields\":[],\"note\":\"\"}"); | 1168 | "\"sensitive\":false,\"fields\":[],\"note\":\"\"}"); |
| 1170 | /* some apps take the note from the source object */ | 1169 | /* some apps take the note from the source object */ |
| 1171 | src = xs_dict_set(src, "note", xs_dict_get(snac.config, "bio")); | 1170 | src = xs_dict_set(src, "note", xs_dict_get(snac.config, "bio")); |
| @@ -2378,6 +2377,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2378 | const char *ruri = xs_dict_get(args, "redirect_uris"); | 2377 | const char *ruri = xs_dict_get(args, "redirect_uris"); |
| 2379 | const char *scope = xs_dict_get(args, "scope"); | 2378 | const char *scope = xs_dict_get(args, "scope"); |
| 2380 | 2379 | ||
| 2380 | /* Ice Cubes sends these values as query parameters, so try these */ | ||
| 2381 | if (name == NULL && ruri == NULL && scope == NULL) { | ||
| 2382 | args = xs_dup(xs_dict_get(req, "q_vars")); | ||
| 2383 | name = xs_dict_get(args, "client_name"); | ||
| 2384 | ruri = xs_dict_get(args, "redirect_uris"); | ||
| 2385 | scope = xs_dict_get(args, "scope"); | ||
| 2386 | } | ||
| 2387 | |||
| 2381 | if (xs_type(ruri) == XSTYPE_LIST) | 2388 | if (xs_type(ruri) == XSTYPE_LIST) |
| 2382 | ruri = xs_dict_get(ruri, 0); | 2389 | ruri = xs_dict_get(ruri, 0); |
| 2383 | 2390 | ||