Mercurial > dovecot > core-2.2
comparison src/lib-oauth2/oauth2-refresh.c @ 21646:7f927c405b2f
lib-oauth2: Support basic authorization
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Tue, 21 Feb 2017 11:18:37 +0200 |
parents | f6d27a985066 |
children | 8afc52576667 |
comparison
equal
deleted
inserted
replaced
21645:a66e16598d6e | 21646:7f927c405b2f |
---|---|
117 req->pool = pool; | 117 req->pool = pool; |
118 req->set = set; | 118 req->set = set; |
119 req->re_callback = callback; | 119 req->re_callback = callback; |
120 req->re_context = context; | 120 req->re_context = context; |
121 | 121 |
122 const char *_url = req->set->refresh_url; | |
123 | 122 |
124 if (http_url_parse(_url, NULL, 0, pool, &url, &error) < 0) { | 123 if (http_url_parse(req->set->refresh_url, NULL, HTTP_URL_ALLOW_USERINFO_PART, |
124 pool, &url, &error) < 0) { | |
125 fail.error = t_strdup_printf("http_url_parse(%s) failed: %s", | 125 fail.error = t_strdup_printf("http_url_parse(%s) failed: %s", |
126 _url, error); | 126 req->set->refresh_url, error); |
127 oauth2_refresh_callback(req, &fail); | 127 oauth2_refresh_callback(req, &fail); |
128 return req; | 128 return req; |
129 } | 129 } |
130 | 130 |
131 req->req = http_client_request_url(req->set->client, "POST", url, | 131 req->req = http_client_request_url(req->set->client, "POST", url, |
139 str_append(payload, "&client_id="); | 139 str_append(payload, "&client_id="); |
140 http_url_escape_param(payload, req->set->client_id); | 140 http_url_escape_param(payload, req->set->client_id); |
141 | 141 |
142 struct istream *is = i_stream_create_from_string(payload); | 142 struct istream *is = i_stream_create_from_string(payload); |
143 | 143 |
144 if (url->user != NULL) | |
145 http_client_request_set_auth_simple(req->req, url->user, url->password); | |
146 | |
144 http_client_request_add_header(req->req, "Content-Type", | 147 http_client_request_add_header(req->req, "Content-Type", |
145 "application/x-www-form-urlencoded"); | 148 "application/x-www-form-urlencoded"); |
146 | 149 |
147 oauth2_request_set_headers(req, input); | 150 oauth2_request_set_headers(req, input); |
148 | 151 |