dermesser / yup-oauth2

An oauth2 client implementation providing the Device, Installed, Service Account, and several more flows.
https://docs.rs/yup-oauth2/
Apache License 2.0
219 stars 114 forks source link

HttpError occur during get token #197

Closed Young-Flash closed 1 year ago

Young-Flash commented 1 year ago

hi there.

I tried the example code in docs for google drive, but it don't work as expectation. There can direct browser to login my google account to google drive, but when I finish login I can't get the token. I trace the code in src/installed.rs::exchange_auth_code, it seems block at let (head, body) = hyper_client.request(request).await?.into_parts();, I print the request in console and get the follow:

Sending request: Request { method: POST, uri: https://oauth2.googleapis.com/token, version: HTTP/1.1, headers: {"content-type": "application/x-www-form-urlencoded"}, body: Body(Full(b"code=4%2F0AWtgzh4033jcoodsXkGo7IUZONaCbuwDEpdkMA46PNTNJ4Lp0JaZR4zgNVD5t17AQPBYYA&client_id=xxx&client_secret=xxx&redirect_uri=http%3A%2F%2F127.0.0.1%3A40161&grant_type=authorization_code")) }

after a while the HttpError occur occur: error: HttpError(hyper::Error(Connect, Custom { kind: Other, error: Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" } })).

I also tried ServiceAccountAuthenticator and get the same error.

Is there anything I miss? Thanks for your time for help.

Young-Flash commented 1 year ago

It's a problem with my network, nothing to do with the code. Sorry to interrupt.

dermesser commented 1 year ago

No worries, relieved to see it's not a serious issue.