File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
use octocrab:: models:: { InstallationRepositories , InstallationToken } ;
2
2
use octocrab:: params:: apps:: CreateInstallationAccessToken ;
3
3
use octocrab:: Octocrab ;
4
+ use url:: Url ;
4
5
5
6
#[ tokio:: main]
6
7
async fn main ( ) -> octocrab:: Result < ( ) > {
@@ -23,11 +24,13 @@ async fn main() -> octocrab::Result<()> {
23
24
let mut create_access_token = CreateInstallationAccessToken :: default ( ) ;
24
25
create_access_token. repositories = vec ! [ "octocrab" . to_string( ) ] ;
25
26
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
+
26
32
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) )
31
34
. await
32
35
. unwrap ( ) ;
33
36
You can’t perform that action at this time.
0 commit comments