Source Square: implement oauth2 java-part #7080
Labels
area/connectors
Connector related issues
autoteam
connectors/source/square
connectors/sources-api
team/connectors-python
square implement oauth2 (java part)
https://developer.squareup.com/reference/square/oauth-api/authorize
=========== JAVA PART ================
Approve access from customer side using:
client_id
scope
https://connect.squareup.com/oauth2/authorize?client_id=sq0idb-...&scope=CUSTOMERS_WRITE+MERCHANT_PROFILE_READ+EMPLOYEES_READ+PAYMENTS_READ+CUSTOMERS_READ+TIMECARDS_READ+ORDERS_READ&session=False&state=82201dd8d83d23cc8a48caf52b
https://connect.squareup.com/oauth2/authorize?client_id=sq0idp-...&scope=ITEMS_READ+CUSTOMERS_READ&session=False&state=82201dd8d83d23cc8a48caf52b
Get redirect url with 'code':
https://airbyte.io/?code=sq0cg-...&response_type=code&state=82201dd8d83d23cc8a48caf52b#_=_
Obtain token using
curl https://connect.squareup.com/oauth2/token
-X POST
-H 'Square-Version: 2021-09-15'
-H 'Content-Type: application/json'
-d '{
"client_id": "sq0idp-...",
"client_secret": "sq0csp-...",
"grant_type": "authorization_code",
"code": "sq0cgp-...",
"scopes": [
"ITEMS_READ",
"MERCHANT_PROFILE_READ",
"EMPLOYEES_READ",
"PAYMENTS_READ",
"CUSTOMERS_READ",
"TIMECARDS_READ",
"ORDERS_READ"
],
}'
RESPONSE:
{
"access_token": "EAAAEPF...",
"token_type": "bearer",
"expires_at": "2021-11-04T16:15:50Z",
"merchant_id": "ML2PMZQ...",
"refresh_token": "EQAAEPhF.....", <======
"short_lived": false
}
OAuth access tokens expire after 30 days.
Refresh tokens do not expire.
============== PYTHON PART =====================
API requests using access_token.
Refresh access_token using refresh_token:
curl https://connect.squareup.com/oauth2/token
-X POST
-H 'Square-Version: 2021-09-15'
-H 'Content-Type: application/json'
-d '{
"client_id": "sq0idp-...",
"client_secret": "sq0csp-...",
"grant_type": "refresh_token",
"refresh_token": "EQAAEPhF...",
"scopes": [
"CUSTOMERS_READ"
]
}'
RESPONSE:
{
"access_token": "EAAAEB7I_...",
"token_type": "bearer",
"expires_at": "2021-11-04T18:55:43Z",
"merchant_id": "ML2PMZQ5....,
"refresh_token": "EQAAEPhF...",
"short_lived": false
}
The text was updated successfully, but these errors were encountered: