diff options
| author | 2024-05-31 01:22:15 +0200 | |
|---|---|---|
| committer | 2024-05-31 01:28:29 +0200 | |
| commit | 795790de08c35571694784f8dac634aa34b4d14f (patch) | |
| tree | be8ea32f8b410a400f9aa53e614a06b7135cdf24 /mastoapi.c | |
| parent | Make Oauth login page actually readable on mobile devices (diff) | |
| download | snac2-795790de08c35571694784f8dac634aa34b4d14f.tar.gz snac2-795790de08c35571694784f8dac634aa34b4d14f.tar.xz snac2-795790de08c35571694784f8dac634aa34b4d14f.zip | |
Fix login with IceCubes and Mastodon on iOS
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 18 |
1 files changed, 12 insertions, 6 deletions
| @@ -339,11 +339,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 339 | const char *cid = xs_dict_get(args, "client_id"); | 339 | const char *cid = xs_dict_get(args, "client_id"); |
| 340 | const char *csec = xs_dict_get(args, "client_secret"); | 340 | const char *csec = xs_dict_get(args, "client_secret"); |
| 341 | const char *ruri = xs_dict_get(args, "redirect_uri"); | 341 | const char *ruri = xs_dict_get(args, "redirect_uri"); |
| 342 | /* FIXME: this 'scope' parameter is mandatory for the official Mastodon API, | 342 | const char *scope = xs_dict_get(args, "scope"); |
| 343 | but if it's enabled, it makes it crash after some more steps, which | ||
| 344 | is FAR WORSE */ | ||
| 345 | const char *scope = NULL; | ||
| 346 | // scope = xs_dict_get(args, "scope"); | ||
| 347 | 343 | ||
| 348 | /* no client_secret? check if it's inside an authorization header | 344 | /* no client_secret? check if it's inside an authorization header |
| 349 | (AndStatus does it this way) */ | 345 | (AndStatus does it this way) */ |
| @@ -1165,8 +1161,10 @@ void credentials_get(char **body, char **ctype, int *status, snac snac) | |||
| 1165 | acct = xs_dict_append(acct, "url", snac.actor); | 1161 | acct = xs_dict_append(acct, "url", snac.actor); |
| 1166 | acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE)); | 1162 | acct = xs_dict_append(acct, "locked", xs_stock(XSTYPE_FALSE)); |
| 1167 | 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()); | ||
| 1168 | 1165 | ||
| 1169 | xs *src = xs_json_loads("{\"privacy\":\"public\"," | 1166 | xs *src = xs_json_loads("{\"privacy\":\"public\", \"language\":\"en\"," |
| 1167 | "\"follow_requests_count\": 0," | ||
| 1170 | "\"sensitive\":false,\"fields\":[],\"note\":\"\"}"); | 1168 | "\"sensitive\":false,\"fields\":[],\"note\":\"\"}"); |
| 1171 | /* some apps take the note from the source object */ | 1169 | /* some apps take the note from the source object */ |
| 1172 | 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")); |
| @@ -2379,6 +2377,14 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2379 | const char *ruri = xs_dict_get(args, "redirect_uris"); | 2377 | const char *ruri = xs_dict_get(args, "redirect_uris"); |
| 2380 | const char *scope = xs_dict_get(args, "scope"); | 2378 | const char *scope = xs_dict_get(args, "scope"); |
| 2381 | 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 | |||
| 2382 | if (xs_type(ruri) == XSTYPE_LIST) | 2388 | if (xs_type(ruri) == XSTYPE_LIST) |
| 2383 | ruri = xs_dict_get(ruri, 0); | 2389 | ruri = xs_dict_get(ruri, 0); |
| 2384 | 2390 | ||