cevoaustralia / aws-google-auth

Provides AWS STS credentials based on Google Apps SAML SSO auth (what a jumble!)
MIT License
537 stars 181 forks source link

New flag `--save-all-html` to record all html content. #181

Open stevemac007 opened 4 years ago

stevemac007 commented 4 years ago

Add logic to trap all GET and POST calls for debug purposes.

max-rocket-internet commented 4 years ago

Great idea 👍

vide commented 4 years ago

When trying this branch to debug my own problem related I guess to #179 I get

ERROR:root:write() argument must be str, not bytes
Traceback (most recent call last):
  File "/home/vide/tmp/aws-google-auth/aws_google_auth/__init__.py", line 79, in cli
    process_auth(args, config)
  File "/home/vide/tmp/aws-google-auth/aws_google_auth/__init__.py", line 243, in process_auth
    google_client.do_login()
  File "/home/vide/tmp/aws-google-auth/aws_google_auth/google.py", line 188, in do_login
    sess = self.get(self.login_url)
  File "/home/vide/tmp/aws-google-auth/aws_google_auth/google.py", line 123, in get
    out.write(response.text.encode('utf-8'))
TypeError: write() argument must be str, not bytes

but if I print before on stdout response.text I do see the HTML

jack1902 commented 4 years ago

@vide if you drop .encode('utf-8') from these lines:

https://github.com/cevoaustralia/aws-google-auth/blob/d6dfdb6be873f507bf075699fcb868902635dc98/aws_google_auth/google.py#L100

and

https://github.com/cevoaustralia/aws-google-auth/blob/d6dfdb6be873f507bf075699fcb868902635dc98/aws_google_auth/google.py#L122

Does the error persist?

vide commented 4 years ago

@jack1902 yeah removing the encode('utf-8') works, I tried it before reporting but only on L122 and then I didn't see it was complaining about L100. Removing it in both places works as expected, I get the files saved to disk

jack1902 commented 4 years ago

wondering if using the -l/--log level would be better to reduce the number of flags the tool has?

I tend to use --log debug --save-failure-html together when debugging. Wondering what others think?