Skip to content

Commit 131ddc0

Browse files
authored
docs: Update manual github app authentication example (XAMPPRocky#610)
* docs: Update manual github app authentication example * fix: access_token_url should not be borrowed reference
1 parent 344cfa7 commit 131ddc0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/github_app_authentication_manual.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use octocrab::models::{InstallationRepositories, InstallationToken};
22
use octocrab::params::apps::CreateInstallationAccessToken;
33
use octocrab::Octocrab;
4+
use url::Url;
45

56
#[tokio::main]
67
async fn main() -> octocrab::Result<()> {
@@ -23,11 +24,13 @@ async fn main() -> octocrab::Result<()> {
2324
let mut create_access_token = CreateInstallationAccessToken::default();
2425
create_access_token.repositories = vec!["octocrab".to_string()];
2526

27+
// By design, tokens are not forwarded to urls that contain an authority. This means we need to
28+
// extract the path from the url and use it to make the request.
29+
let access_token_url =
30+
Url::parse(installations[0].access_tokens_url.as_ref().unwrap()).unwrap();
31+
2632
let access: InstallationToken = octocrab
27-
.post(
28-
installations[0].access_tokens_url.as_ref().unwrap(),
29-
Some(&create_access_token),
30-
)
33+
.post(access_token_url.path(), Some(&create_access_token))
3134
.await
3235
.unwrap();
3336

0 commit comments

Comments
 (0)