suds-community / suds

Suds is a lightweight SOAP python client for consuming Web Services. A community fork of the jurko fork.
https://suds.readthedocs.io/
GNU Lesser General Public License v3.0
173 stars 56 forks source link

OAuth2 #90

Open dedalus2000 opened 1 year ago

dedalus2000 commented 1 year ago

Dear all, It would be helpful to allow OAuth2 authentication. For example:

# https://docs.authlib.org/en/latest/client/oauth2.html
from authlib.integrations.requests_client import OAuth2Session
client = OAuth2Session(CLIENT_ID, CLIENT_SECRET, scope=OAUTH_SCOPE)
# Redirect to Authorization Endpoint
uri, state = client.create_authorization_url(authorization_url) 
# Fetch Token
token = client.fetch_token(access_token_url, authorization_response=uri, username=saak_key, password=sask_key)
session = OAuth2Session(token=token)

Now we should be able to use the session in some ways.

It may be necessary to add a "soapheader"

phillbaker commented 1 year ago

Hello, thanks for opening an issue. This library won’t support the full OAuth flow, but should already support authentication using OAuth generated tokens.

Typically this requires sending a Authorization header with a Bearer token. Setting both soapheaders and HTTP headers is supported already, please see the README for configuring the client. Specifics may depend on the API you’re integrating with.

On Tue, Apr 4, 2023 at 2:48 AM dedalus2000 @.***> wrote:

Dear all, It would be helpful to allow OAuth2 authentication. For ie:

https://docs.authlib.org/en/latest/client/oauth2.html

from authlib.integrations.requests_client import OAuth2Session client = OAuth2Session(CLIENT_ID, CLIENT_SECRET, scope=OAUTH_SCOPE)

Redirect to Authorization Endpoint

uri, state = client.create_authorization_url(authorization_url)

Fetch Token

token = client.fetch_token(access_token_url, authorization_response=uri, username=saak_key, password=sask_key) session = OAuth2Session(token=token)

Now we should be able to use session in some ways.

It may be necessary to add a "soapheader"

— Reply to this email directly, view it on GitHub https://github.com/suds-community/suds/issues/90, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXCKO6ZKH46LII2J2QY3DW7O73ZANCNFSM6AAAAAAWSINMLY . You are receiving this because you are subscribed to this thread.Message ID: @.***>