mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Posting now working
This commit is contained in:
@@ -168,6 +168,8 @@ class AyrshareClient:
|
||||
"profileKey": profile_key,
|
||||
}
|
||||
|
||||
headers = self.headers
|
||||
headers["Profile-Key"] = profile_key
|
||||
if logout is not None:
|
||||
payload["logout"] = logout
|
||||
if redirect is not None:
|
||||
@@ -183,7 +185,7 @@ class AyrshareClient:
|
||||
if email is not None:
|
||||
payload["email"] = email.__dict__
|
||||
|
||||
response = self._requests.post(self.JWT_ENDPOINT, json=payload)
|
||||
response = self._requests.post(self.JWT_ENDPOINT, json=payload, headers=headers)
|
||||
|
||||
if not response.ok:
|
||||
try:
|
||||
@@ -280,7 +282,6 @@ class AyrshareClient:
|
||||
response.status_code,
|
||||
)
|
||||
|
||||
logger.info(f"Profile created: {response_data}")
|
||||
return ProfileResponse(**response_data)
|
||||
|
||||
def create_post(
|
||||
|
||||
@@ -430,15 +430,19 @@ async def get_ayrshare_sso_url(
|
||||
Returns:
|
||||
dict: Contains the SSO URL for Ayrshare integration
|
||||
"""
|
||||
# Generate JWT and get SSO URL
|
||||
client = AyrshareClient()
|
||||
|
||||
# Get or create profile key
|
||||
profile_key = creds_manager.store.get_ayrshare_profile_key(user_id)
|
||||
if not profile_key:
|
||||
logger.info(f"Creating new Ayrshare profile for user {user_id}")
|
||||
# Create new profile if none exists
|
||||
client = AyrshareClient()
|
||||
profile = client.create_profile(title=f"User {user_id}", messaging_active=True)
|
||||
profile_key = profile.profileKey
|
||||
creds_manager.store.set_ayrshare_profile_key(user_id, profile_key)
|
||||
else:
|
||||
logger.info(f"Using existing Ayrshare profile for user {user_id}")
|
||||
|
||||
# Convert SecretStr to string if needed
|
||||
profile_key_str = (
|
||||
@@ -447,28 +451,32 @@ async def get_ayrshare_sso_url(
|
||||
else str(profile_key)
|
||||
)
|
||||
|
||||
# Generate JWT and get SSO URL
|
||||
client = AyrshareClient()
|
||||
private_key = settings.secrets.ayrshare_jwt_key
|
||||
|
||||
jwt_response = client.generate_jwt(
|
||||
private_key=settings.secrets.ayrshare_jwt_secret,
|
||||
profile_key=profile_key_str,
|
||||
allowed_social=[
|
||||
SocialPlatform.FACEBOOK,
|
||||
SocialPlatform.TWITTER,
|
||||
SocialPlatform.LINKEDIN,
|
||||
SocialPlatform.INSTAGRAM,
|
||||
SocialPlatform.YOUTUBE,
|
||||
SocialPlatform.REDDIT,
|
||||
SocialPlatform.TELEGRAM,
|
||||
SocialPlatform.GMB,
|
||||
SocialPlatform.PINTEREST,
|
||||
SocialPlatform.TIKTOK,
|
||||
SocialPlatform.BLUESKY,
|
||||
],
|
||||
expires_in=2880,
|
||||
verify=True,
|
||||
)
|
||||
try:
|
||||
logger.info(f"Generating JWT for user {user_id}")
|
||||
jwt_response = client.generate_jwt(
|
||||
private_key=private_key,
|
||||
profile_key=profile_key_str,
|
||||
allowed_social=[
|
||||
SocialPlatform.FACEBOOK,
|
||||
SocialPlatform.TWITTER,
|
||||
SocialPlatform.LINKEDIN,
|
||||
SocialPlatform.INSTAGRAM,
|
||||
SocialPlatform.YOUTUBE,
|
||||
SocialPlatform.REDDIT,
|
||||
SocialPlatform.TELEGRAM,
|
||||
SocialPlatform.GMB,
|
||||
SocialPlatform.PINTEREST,
|
||||
SocialPlatform.TIKTOK,
|
||||
SocialPlatform.BLUESKY,
|
||||
],
|
||||
expires_in=2880,
|
||||
verify=True,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error generating JWT for user {user_id}: {e}")
|
||||
raise HTTPException(status_code=500, detail="Failed to generate JWT")
|
||||
|
||||
expire_at = datetime.now(timezone.utc) + timedelta(minutes=2880)
|
||||
return {"sso_url": jwt_response.url, "expire_at": expire_at.isoformat()}
|
||||
|
||||
@@ -439,8 +439,7 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):
|
||||
smartlead_api_key: str = Field(default="", description="SmartLead API Key")
|
||||
zerobounce_api_key: str = Field(default="", description="ZeroBounce API Key")
|
||||
ayrshare_api_key: str = Field(default="", description="Ayrshare API Key")
|
||||
ayrshare_jwt_secret: str = Field(default="", description="Aryshare private Key")
|
||||
|
||||
ayrshare_jwt_key: str = Field(default="", description="Ayrshare private Key")
|
||||
# Add more secret fields as needed
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
|
||||
Reference in New Issue
Block a user