Hi there!
Thanks for writing in.
Our DEMO_TOKEN is made available for testing resource-based requests but does not function with the authentication (OAuth 2.0) API. When you're approaching these steps, it's best to forget about the DEMO_TOKEN completely. It represents a specific relationship between the demo district and a special demo application used in our API Explorer.
If you're trying to retrieve negotiated district bearer tokens form GET oauth/tokens, then you must leverage your client ID and secret, but in a very specific way. I notice you pass client_secret as a query parameter in your first example curl request -- you don't want to ever send this value in plain text or as a query parameter. You'll also never want to use bearer-token based auth with this method -- you're using this method to obtain bearer tokens. Instead, you use your client ID and client secret as a username and password value for what's called "HTTP Basic Auth."
With curl, specifying basic auth credentials is simple -- if you client ID were "abcd" and your client secret were "efgh", and instead of using the '-H "Authorization: Bearer..." directive, you can use "-u abcd:efgh" to specify that as your user/password combination.
If you're trying to obtain the district bearer tokens already associated with your app, the request might look something like:
If you're trying to exchange a code value that you received on your redirect, it gets a little more complicated and curl isn't necessarily the right tool for the job since all the components of the OAuth 2.0 sequence are time-sensitive. But assuming the same redirect value and code you've received here, the request should look more like:
curl -u abcd:efgh -X POST https://clever.com/oauth/tokens -d "grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Flogin%2Foauth&code=f0401268ba5c589a05184292e21d299a74ea927d"
Notice I'm setting the HTTP method to POST (a GET is not correct when exchanging codes for tokens). I'm not explicitly sending client ID or secret as query parameters -- they're being used to create a HTTP basic authorization instead.
What framework are you working with?
Best,
Taylor Singletary
Clever developer relations