Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Square: implement oauth2 java-part #7080

Closed
Tracked by #6282 ...
midavadim opened this issue Oct 15, 2021 · 2 comments
Closed
Tracked by #6282 ...

Source Square: implement oauth2 java-part #7080

midavadim opened this issue Oct 15, 2021 · 2 comments

Comments

@midavadim
Copy link
Collaborator

midavadim commented Oct 15, 2021

square implement oauth2 (java part)

https://developer.squareup.com/reference/square/oauth-api/authorize

=========== JAVA PART ================

  1. 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

  2. Get redirect url with 'code':

    https://airbyte.io/?code=sq0cg-...&response_type=code&state=82201dd8d83d23cc8a48caf52b#_=_

  3. 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 =====================

  1. API requests using access_token.

  2. 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
    }

@etsybaev
Copy link
Contributor

To check
#6842

@lazebnyi lazebnyi changed the title square implement oauth2 (java part) Source Square: implement oauth2 java-part Nov 8, 2021
@sherifnada sherifnada added the area/connectors Connector related issues label Nov 15, 2021
@artem1205
Copy link
Collaborator

Implemented in #6842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

6 participants