summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-08-31 06:23:04 -0400
committerPaul Woolcock <paul@woolcock.us>2018-08-31 08:19:35 -0400
commit8db3d18219a8a3e3d1d9fb1e31ad53c13e644d2f (patch)
tree87c287e7de7ac0e8f1a0660cdb0076265d75bfb3 /src
parent034bd4e6d107f5a48f560327cc2800cb41995f13 (diff)
Make sure scopes are percent-encoded when making the URL
Diffstat (limited to 'src')
-rw-r--r--src/registration.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/registration.rs b/src/registration.rs
index d09c180..c195042 100644
--- a/src/registration.rs
+++ b/src/registration.rs
@@ -2,6 +2,7 @@ use std::borrow::Cow;
use reqwest::{Client, RequestBuilder, Response};
use try_from::TryInto;
+use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};
use apps::{App, AppBuilder};
use http_send::{HttpSend, HttpSender};
@@ -190,9 +191,11 @@ impl<H: HttpSend> Registered<H> {
/// Returns the full url needed for authorisation. This needs to be opened
/// in a browser.
pub fn authorize_url(&self) -> Result<String> {
+ let scopes = format!("{}", self.scopes);
+ let scopes: String = utf8_percent_encode(&scopes, DEFAULT_ENCODE_SET).collect();
let url = format!(
"{}/oauth/authorize?client_id={}&redirect_uri={}&scope={}&response_type=code",
- self.base, self.client_id, self.redirect, self.scopes,
+ self.base, self.client_id, self.redirect, scopes,
);
Ok(url)