Not sure what’s going on here.
I am trying to implement a authlib to access the squarespace API via OAuth. I have implemented github and other 3rd party services with little effort, but specifically with squarespace, errors are persisting. Unfortunately squarespace is crucial to our web application at this point. I have now boiled this down to a very simple flask app as an example. Here is the code:
s
import os
from authlib.integrations.flask_client import OAuth
from flask import Flask, url_for, redirect
app = Flask(__name__)
app.secret_key = "ghaigeowij"
oauth = OAuth(app)
oauth.register(
name='squarespace',
authorize_url='https://login.squarespace.com/api/1/login/oauth/provider/authorize',
access_token_url='https://login.squarespace.com/api/1/login/oauth/provider/tokens',
client_id=os.environ.get('SQUARESPACE_CLIENT_ID'),
client_secret=str(os.environ.get('SQUARESPACE_SECRET_KEY')),
client_kwargs={
'scope': 'website.inventory,website.orders',
},
)
oauth.register(
name='github',
client_id=os.environ.get('GITHUB_CLIENT_ID'),
client_secret=str(os.environ.get('GITHUB_CLIENT_SECRET')),
access_token_url='https://github.com/login/oauth/access_token',
authorize_url='https://github.com/login/oauth/authorize',
api_base_url='https://api.github.com/',
client_kwargs={'scope': 'user:email'}, # Modify scope as needed
)
@app.route('/login')
def login():
redirect_uri = "https://platform.orangeisbetter.com/system/oauth/squarespace/callback"
return oauth.squarespace.authorize_redirect(redirect_uri)
@app.route('/authorize')
def authorize():
token = oauth.squarespace.authorize_access_token()
print(token)
# do something with the token and profile
return redirect('/')