You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert_eq!(str_code,"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.");
let mut stream = documents::list(&session, "tests");
93
+
while let Some(Ok(doc_result)) = stream.next().await {
93
94
// The document is wrapped in a Result<> because fetching new data could have failed
94
-
let (doc, _metadata) =doc_result?;
95
+
let (doc, _metadata) = doc_result;
96
+
let doc: DemoDTO = doc;
95
97
println!("{:?}", doc);
96
98
}
97
99
```
@@ -102,7 +104,7 @@ You cannot keep the iterator for long or expect new documents to appear in an on
102
104
For quering the database you would use the `query` method.
103
105
In the following example the collection "tests" is queried for document(s) with the "id" field equal to "Sam Weiss".
104
106
105
-
```rust
107
+
```rust,no_run
106
108
use firestore_db_and_auth::{documents, dto};
107
109
108
110
let values = documents::query(&session, "tests", "Sam Weiss".into(), dto::FieldOperator::EQUAL, "id")?;
@@ -128,7 +130,7 @@ This custom error type wraps all possible errors (IO, Reqwest, JWT errors etc)
128
130
and Google REST API errors. If you want to specifically check for an API error,
129
131
you could do so:
130
132
131
-
```rust
133
+
```rust,no_run
132
134
use firestore_db_and_auth::{documents, errors::FirebaseError};
133
135
134
136
let r = documents::delete(&session, "tests/non_existing", true);
@@ -151,7 +153,7 @@ It may be the collection or document id or any other context information.
151
153
The file should contain `"private_key_id": ...`.
152
154
2. Add another field `"api_key" : "YOUR_API_KEY"` and replace YOUR_API_KEY with your *Web API key*, to be found in the [Google Firebase console](https://console.firebase.google.com) in "Project Overview -> Settings - > General".
153
155
154
-
```rust
156
+
```rust,no_run
155
157
use firestore_db_and_auth::{Credentials, ServiceSession};
156
158
157
159
/// Create credentials object. You may as well do that programmatically.
@@ -170,7 +172,7 @@ let session = ServiceSession::new(&cred)
170
172
You can create a user session in various ways.
171
173
If you just have the firebase Auth user_id, you would follow these steps:
172
174
173
-
```rust
175
+
```rust,no_run
174
176
use firestore_db_and_auth::{Credentials, sessions};
175
177
176
178
/// Create credentials object. You may as well do that programmatically.
@@ -187,14 +189,14 @@ let session = UserSession::by_user_id(&cred, "the_user_id")
187
189
188
190
If you already have a valid refresh token and want to generate an access token (and a session object), you do this instead:
189
191
190
-
```rust
192
+
```rust,no_run
191
193
let refresh_token = "fkjandsfbajsbfd;asbfdaosa.asduabsifdabsda,fd,a,sdbasfadfasfas.dasdasbfadusbflansf";
192
194
let session = UserSession::by_refresh_token(&cred, &refresh_token)?;
193
195
```
194
196
195
197
Another way of retrieving a session object is by providing a valid access token like so:
196
198
197
-
```rust
199
+
```rust,no_run
198
200
let access_token = "fkjandsfbajsbfd;asbfdaosa.asduabsifdabsda,fd,a,sdbasfadfasfas.dasdasbfadusbflansf";
199
201
let session = UserSession::by_access_token(&cred, &access_token)?;
200
202
```
@@ -220,7 +222,7 @@ First download the 2 public key files:
220
222
221
223
Create a `Credentials` object like so:
222
224
223
-
```rust
225
+
```rust,no_run
224
226
use firestore_db_and_auth::Credentials;
225
227
let c = Credentials::new(include_str!("firebase-service-account.json"))?
0 commit comments