OAuth Initiation Issue with Airbyte Python SDK

Summary

User is attempting to initiate OAuth for a source using the Airbyte Python SDK but is encountering issues with the returned URL not working. They are unsure if the function is implemented correctly or if the redirect URL is appropriate, as both provided URLs have failed.


Question

Hello, everyone :hand:
I am trying to use airbyte Python SDK to initiate OAuth for a source
I’ve set the function based on the documentation of Airbyte github repo https://github.com/airbytehq/airbyte-api-python-sdk/blob/main/docs/sdks/sources/README.md

And this what the function looks like

    o_auth_actor = getattr(shared.OAuthActorNames, actor_name, None)
    if o_auth_actor is None:
        raise ValueError(f"Invalid OAuthActorNames key: {actor_name}")
    req = shared.InitiateOauthRequest(
        o_auth_input_configuration=shared.OAuthInputConfiguration(),
        redirect_url='<https://cloud.airbyte.com/auth_flow>',
        source_type=o_auth_actor,
        workspace_id=workspace_id,
    )

    res = s.sources.initiate_o_auth(req)
    if res.status_code == 200:
        # Parse the JSON response to get the URL
        response_data = res.raw_response.json()
        # Assuming the URL is in the response data under a specific key, e.g., 'oauth_url'
        oauth_url = response_data.get('consentUrl', None)
        if oauth_url:
            return oauth_url
        else:
            raise ValueError("OAuth URL not found in the response.")
    else:
        # Handle non-200 responses or add additional error handling as needed
        raise ValueError(f"Failed to initiate OAuth. Status code: {res.status_code}")```
The function is returning a url and when accessing it is not working.
I am trying to initiate OAuth for SNAPCHAT_MARKETING as actor_name and I am using cloud airbyte.

When hitting the URL snapchat is returning something went wrong without any additional info.
But trying to create SNAPCHAT source on the cloud airbyte UI it is working.

First I need to verify if the function is correctly developed or I am missing something
Second if I am using the right redirectUrl

What I’ve tried as redirect URL is the following:
• <https://cloud.airbyte.com/auth_flow> got it from the response when initiating OAuth using the cloud UI
• <https://cloud.airbyte.io/v1/api/oauth/callback> got it from <https://reference.airbyte.com/reference/initiateoauth> as set in the examples
Both Failed but I am not sure if it is from the redirect URL or something else

Thank you for your help in advanced!

<br>

---

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. [Click here](https://airbytehq.slack.com/archives/C021JANJ6TY/p1707403037413569) if you want
to access the original thread.

[Join the conversation on Slack](https://slack.airbyte.com)

<sub>
['airbyte', 'python-sdk', 'oauth', 'snapschat-marketing', 'redirect-url']
</sub>