@@ -254,7 +254,13 @@ def decorator(schema):
254254A valid response will resemble:
255255
256256```json
257- {"access_token":"BASE64_ENCODED_JWT","expires_in":10800,"token_type":"Bearer"}
257+ {
258+ "access_token":"BASE64_ENCODED_JWT",
259+ "id_token": "ENCODED_ID_INFORMATION",
260+ "scope": "openid profile email",
261+ "expires_in":10800,
262+ "token_type":"Bearer"
263+ }
258264```
259265
260266Requests to the API need to send the access token in the Authorization header:
@@ -264,8 +270,24 @@ def decorator(schema):
264270 --url "https://api.solarforecastarbiter.org/endpoint"
265271```
266272
267- Extracting and using the access token might look like:
273+ Extracting an access token into an environment variable and
274+ using it to retrieve data from the api might look like:
275+
276+ Using GNU grep and awk:
277+ ```
278+ export ACCESS_TOKEN=\\
279+ $(curl -s --request POST \\
280+ --url 'https://solarforecastarbiter.auth0.com/oauth/token' \\
281+ --header 'content-type: application/json' \\
282+ --data '{"grant_type": "password", "username": "[email protected] ", "password": "Thepassword123!", "audience": "https://api.solarforecastarbiter.org", "client_id": "c16EJo48lbTCQEhqSztGGlmxxxmZ4zX7"}'\\ 283+ | grep -oP '"access_token"\:"\K[^"]+'\\
284+ | awk '{ print $1 }' )
285+
286+ curl --header "Authorization: Bearer $ACCESS_TOKEN" \\
287+ --url "https://api.solarforecastarbiter.org/observations/"
288+ ```
268289
290+ Using the jq utility available at: https://stedolan.github.io/jq/.
269291```
270292export ACCESS_TOKEN=\\
271293$(curl -s --request POST \\
@@ -277,7 +299,7 @@ def decorator(schema):
277299curl --header "Authorization: Bearer $ACCESS_TOKEN" \\
278300 --url "https://api.solarforecastarbiter.org/observations/"
279301```
280- The jq utility can be obtained at https://stedolan.github.io/jq/.
302+
281303
282304Python users may want to use a libarary like
283305[Authlib](https://docs.authlib.org/en/latest/client/oauth2.html#oauth2session-for-password)
0 commit comments