Tweak .well-known fallback handling

This raises a better error than "'NoneType' is not iterable" in case
neither URL return something useful. Also reports the RFC path rather
than the OpenID one in the final traceback.
1 files changed, 15 insertions(+), 6 deletions(-)

M httpie_oauth2.py
M httpie_oauth2.py +15 -6
@@ 60,15 60,24 @@ class OAuth2Issuer(BaseConfigDict):
         "RFC 8414: OAuth 2.0 Authorization Server Metadata"
 
         if not self["meta"]:
-            for wellknown in ["oauth-authorization-server", "openid-configuration"]:
+            try:
+                oauth_meta = http_get(
+                    self.issuer + "/.well-known/oauth-authorization-server"
+                )
+                oauth_meta.raise_for_status()
+                self["meta"] = oauth_meta.json()
+                return self["meta"]
+            except:
                 try:
-                    self["meta"] = http_get(
-                        self.issuer + "/.well-known/" + wellknown
-                    ).json()
-                    break
+                    oidc_meta = http_get(
+                        self.issuer + "/.well-known/openid-configuration"
+                    )
+                    self["meta"] = oidc_meta.json()
+                    return self["meta"]
                 except:
                     pass
-            self.save()
+                raise  # error about first endpoint
+
         return self["meta"]
 
     def register(self, data: dict):