Skip to content

Commit 0da5249

Browse files
committed
Improve docs on tokens and login.
1 parent 1a3cebe commit 0da5249

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/lib.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn default_url() -> Url {
164164
}
165165

166166
impl<C> Api<C> {
167-
/// Creates a new API instance for the official server with the `https://screeps.com/api/` base
167+
/// Creates a new API instance for the official server with the `"https://screeps.com/api/"` base
168168
/// url.
169169
///
170170
/// Use [`Api::with_url`] or [`Api::set_url`] to change to a custom server.
@@ -200,6 +200,8 @@ impl<C> Api<C> {
200200

201201
/// Sets the auth token this api client will use.
202202
///
203+
/// See [the screeps docs page](https://docs.screeps.com/auth-tokens.html) for information on tokens.
204+
///
203205
/// See also [`Api::with_token`].
204206
#[inline]
205207
pub fn set_token<T: Into<Token>>(&mut self, token: T) {
@@ -208,6 +210,8 @@ impl<C> Api<C> {
208210

209211
/// Sets the auth token this api client will use, and returns the client.
210212
///
213+
/// See [the screeps docs page](https://docs.screeps.com/auth-tokens.html) for information on tokens.
214+
///
211215
/// See also [`Api::set_token`].
212216
#[inline]
213217
pub fn with_token<T: Into<Token>>(mut self, token: T) -> Self {
@@ -267,9 +271,15 @@ impl<C: hyper::client::connect::Connect + 'static> Api<C> {
267271
self.request(endpoint).post(request_text)
268272
}
269273

270-
/// Logs in with the given username and password and returns a result containing the token.
274+
/// Logs in with the given username and password and stores the authenticated token in self.
275+
///
276+
/// *Note:* since [the official server implemented auth tokens][blog], this method has only
277+
/// worked for private servers with the [screepsmod-auth] mod.
271278
///
272-
/// Use `client.set_token(logged_in.token)` to let the client use the token from logging in.
279+
/// Use [`Api::set_token`] instead for the official server.
280+
///
281+
/// [blog]: https://blog.screeps.com/2017/12/auth-tokens/
282+
/// [screepsmod-auth]: https://github.com/ScreepsMods/screepsmod-auth
273283
pub fn login<'b, U, V>(
274284
&self,
275285
username: U,

src/sync.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,24 @@ impl<C: hyper::client::connect::Connect + 'static> SyncApi<C> {
141141

142142
/// Sets the auth token this api client will use, and returns the client.
143143
///
144+
/// See [the screeps docs page](https://docs.screeps.com/auth-tokens.html) for information on tokens.
145+
///
144146
/// See also [`Api::set_token`].
145147
#[inline]
146148
pub fn with_token<T: Into<Token>>(mut self, token: T) -> Self {
147149
self.set_token(token.into());
148150
self
149151
}
150152

151-
/// Logs in with the given username and password and gets an authentication token as the
152-
/// result.
153+
/// Logs in with the given username and password and stores the authenticated token in self.
154+
///
155+
/// *Note:* since [the official server implemented auth tokens][blog], this method has only
156+
/// worked for private servers with the [screepsmod-auth] mod.
153157
///
154-
/// The authentication token will then be stored in this client.
158+
/// Use [`Api::set_token`] instead for the official server.
159+
///
160+
/// [blog]: https://blog.screeps.com/2017/12/auth-tokens/
161+
/// [screepsmod-auth]: https://github.com/ScreepsMods/screepsmod-auth
155162
pub fn login<'b, U, V>(&mut self, username: U, password: V) -> Result<(), Error>
156163
where
157164
U: Into<Cow<'b, str>>,

0 commit comments

Comments
 (0)