Quick “Hello World”
Before doing a full integration with the Slice API, many developers want to experiment with our data and get a sense of how they might build it into their apps. We recommend using the Google OAuth 2.0 Playground to get quick access to your Slice data.
Google’s OAuth 2.0 Playground is a powerful tool that goes through the OAuth 2.0 authorization flow with any OAuth 2.0 provider and obtains a valid access token, then lets the user make any REST request using that token.
It makes it easy to explore a new REST API, as well as validating that it an API is working is expected. Once an access token is obtained it can be put into other REST tools such as Paw, used for authorizing a “curl” request on the command line, or even hardcoded into a prototype so that you can use live Slice data without needing to go through a full Slice OAuth integration.
To get started accessing the Slice API with the OAuth 2.0 Playground, follow these steps:
- Visit https://developer.slice.com and scroll down to “Pick your Plan”, and select “Sign up for OAuth”. Create a new OAuth application and make sure that the redirect URL is https://developers.google.com/oauthplayground. Make a note of the client id and secret that is assigned for this application.
- Go to https://developer.slice.com/playground
- Click the “gear” icon in the top right to configure the OAuth playground.
- Make sure to use the following settings:
- OAuth flow: server-side (probably the default)
- OAuth endpoints: Custom
- Authorization endpoint: https://api.slice.com/oauth/authorize
- Token endpoint: https://api.slice.com/oauth/token
- Access token location: Authorization header w/ Bearer prefix (probably the default)
- OAuth client id and client secret: use the client id and secret that corresponds to your OAuth application
- Close the settings panel.
- On the left, under “Step 1: select & authorize APIs”, enter “/” for a custom scope and click “Authorize APIs”.
- You’ll be taken through a series of authorization steps for Slice to share your data with the OAuth 2.0 playground – the exact steps will vary depending on your current logged-in state, but take every affirmative prompt you are given (i.e. log in, accept terms, and click “authorize” when asked to do so).
- Eventually you’ll be redirected back to the OAuth 2.0 playground and now you’ll be in “Step 2: Exchange authorization code for tokens”. There should be an authorization code pre-filled in the box labeled “authorization code”. Click the button that says “Exchange authorization code for tokens”.
- A refresh token and access token will appear, along with a timer that is counting down to when the access token expires. You can choose to auto-refresh the access token if you expect to be still working with it when it expires (but note that this will cause a new code to be generated, so if you copy-paste the code into a different application it will still expire).
- Proceed on to “Step 3: Configure Request to API”.
- Let’s start with a simple request to make sure everything is working. Use the following settings: - HTTP Method: GET (probably the default) - Request URI: https://api.slice.com/api/v1/users/self - Click “Send the request”. You should see a response that contains a bunch of information about your user account in Slice.
You’re all set – have fun!