Skip to content

Instantly share code, notes, and snippets.

@nono
Last active December 15, 2016 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nono/57f6d472afff6a570a5f1c477d2e79a3 to your computer and use it in GitHub Desktop.
Save nono/57f6d472afff6a570a5f1c477d2e79a3 to your computer and use it in GitHub Desktop.
Command line to test the creation of an OAuth2 client with the new cozy stack
cozy@cozy-stack-v2:~$ ./cozy-stack instances add test.bruno.fr
INFO[0000] Instance created with success for domain test.bruno.fr
INFO[0000] Registration token: "37cddf40d7724988860fa0e03efd30fe"
cozy@cozy-stack-v2:~$ http -v --form POST :8080/register Host:test.bruno.fr registerToken=37cddf40d7724988860fa0e03efd30fe passphrase=azerty
POST /register HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 64
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
registerToken=37cddf40d7724988860fa0e03efd30fe&passphrase=azerty
HTTP/1.1 303 See Other
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Date: Thu, 15 Dec 2016 09:07:11 GMT
Location: https://onboarding.test.bruno.fr/
Set-Cookie: cozysessid=AAAAAFhSXT81MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxN2Y5NjCmp2Ja56hPgHwufpJCBBGJC2mLeJ5LCRrFFkHwaVVa; Path=/; Domain=test.bruno.fr; Max-Age=604800; HttpOnly; Secure
cozy@cozy-stack-v2:~$ http -v POST :8080/auth/register Host:test.bruno.fr Content-Type:application/json 'redirect_uris:=["https://client.example.org/oauth/callback"]' client_name=client software_id=github.com/example/client
POST /auth/register HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 133
Content-Type: application/json
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
{
"client_name": "client",
"redirect_uris": [
"https://client.example.org/oauth/callback"
],
"software_id": "github.com/example/client"
}
HTTP/1.1 201 Created
Content-Length: 625
Content-Type: application/json; charset=utf-8
Date: Thu, 15 Dec 2016 09:21:13 GMT
{
"client_id": "51e4e0b39e2b58e22fb7d4a63401850d",
"client_name": "client",
"client_secret": "hps2RwGhNVzkEOZN-JcDRX80Xg1IFMhr",
"client_secret_expires_at": 0,
"grant_types": [
"authorization_code",
"refresh_token"
],
"redirect_uris": [
"https://client.example.org/oauth/callback"
],
"registration_access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyZWdpc3RyYXRpb24iLCJpYXQiOjE0ODE3OTM2NzMsImlzcyI6InRlc3QuYnJ1bm8uZnIiLCJzdWIiOiI1MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxODUwZCJ9.xNflXrtjwRxxpUvMBXotkPB8l9Oltlc--hohkAYgOQNBI1vawZa5pj6kXRT8JC4xpv1qc0SCCTINRKIKKyn82Q",
"response_types": [
"code"
],
"software_id": "github.com/example/client"
}
cozy@cozy-stack-v2:~$ http -v GET ':8080/auth/authorize?client_id=51e4e0b39e2b58e22fb7d4a63401850d&redirect_uri=https://client.example.org/oauth/callback&state=42&response_type=code&scope=files:read' Host:test.bruno.fr Cookie:cozysessid=AAAAAFhSYW81MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxOTAzYcP0adhtS_xgHKuvum_-dCBQTvH8eatjkXzlECdJM0lD
GET /auth/authorize?client_id=51e4e0b39e2b58e22fb7d4a63401850d&redirect_uri=https://client.example.org/oauth/callback&state=42&response_type=code&scope=files:read HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: cozysessid=AAAAAFhSYW81MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxOTAzYcP0adhtS_xgHKuvum_-dCBQTvH8eatjkXzlECdJM0lD
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
HTTP/1.1 200 OK
Content-Length: 1913
Content-Type: text/html; charset=utf-8
Date: Thu, 15 Dec 2016 09:28:28 GMT
Set-Cookie: _csrf=heCXQbvdjWokoFxeRki7I5BVGFUebulY; Expires=Thu, 15 Dec 2016 10:28:28 GMT; HttpOnly; Secure
Vary: Cookie
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Cozy</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/settings/theme.css">
<link rel="stylesheet" href="/assets/styles/stack.css">
<link rel="icon" type="image/png" href="/assets/images/happycloud.png" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
</head>
<body>
<main role="application">
<section class="popup">
<header>
<a href="https://cozy.io" target="_blank" title="Cozy Website"></a>
</header>
<div class="container">
<form method="POST" action="/auth/authorize" class="login auth">
<input type="hidden" name="csrf_token" value="heCXQbvdjWokoFxeRki7I5BVGFUebulY" />
<input type="hidden" name="client_id" value="51e4e0b39e2b58e22fb7d4a63401850d" />
<input type="hidden" name="state" value="42" />
<input type="hidden" name="redirect_uri" value="https://client.example.org/oauth/callback" />
<input type="hidden" name="scope" value="files:read" />
<div role="region">
<h1>Authorize application</h1>
<p class="help">
<strong>
client
</strong>
would like permission to access your Cozy.
This permission give access to:
</p>
<ul>
<li>files:read</li>
</ul>
</div>
<footer>
<div class="controls">
<button type="submit" class="btn btn-primary">Accept</button>
</div>
</footer>
</form>
</div>
</section>
</main>
</body>
</html>
cozy@cozy-stack-v2:~$ http -v --form POST :8080/auth/authorize client_id=51e4e0b39e2b58e22fb7d4a63401850d redirect_uri=https://client.example.org/oauth/callback state=42 scope=files:read csrf_token=heCXQbvdjWokoFxeRki7I5BVGFUebulY Host:test.bruno.fr 'Cookie:cozysessid=AAAAAFhSYW81MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxOTAzYcP0adhtS_xgHKuvum_-dCBQTvH8eatjkXzlECdJM0lD;_csrf=heCXQbvdjWokoFxeRki7I5BVGFUebulY'
POST /auth/authorize HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 179
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Cookie: cozysessid=AAAAAFhSYW81MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxOTAzYcP0adhtS_xgHKuvum_-dCBQTvH8eatjkXzlECdJM0lD;_csrf=heCXQbvdjWokoFxeRki7I5BVGFUebulY
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
client_id=51e4e0b39e2b58e22fb7d4a63401850d&redirect_uri=https%3A%2F%2Fclient.example.org%2Foauth%2Fcallback&state=42&scope=files%3Aread&csrf_token=heCXQbvdjWokoFxeRki7I5BVGFUebulY
HTTP/1.1 302 Found
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Date: Thu, 15 Dec 2016 09:30:29 GMT
Location: https://client.example.org/oauth/callback?access_code=51e4e0b39e2b58e22fb7d4a634019fa8&state=42#
Set-Cookie: _csrf=heCXQbvdjWokoFxeRki7I5BVGFUebulY; Expires=Thu, 15 Dec 2016 10:30:29 GMT; HttpOnly; Secure
Vary: Cookie
cozy@cozy-stack-v2:~$ http -v --form POST :8080/auth/access_token grant_type=authorization_code code=51e4e0b39e2b58e22fb7d4a634019fa8 client_id=51e4e0b39e2b58e22fb7d4a63401850d client_secret=hps2RwGhNVzkEOZN-JcDRX80Xg1IFMhr scope=files:read Host:test.bruno.fr
POST /auth/access_token HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 176
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
grant_type=authorization_code&code=51e4e0b39e2b58e22fb7d4a634019fa8&client_id=51e4e0b39e2b58e22fb7d4a63401850d&client_secret=hps2RwGhNVzkEOZN-JcDRX80Xg1IFMhr&scope=files%3Aread
HTTP/1.1 200 OK
Content-Length: 643
Content-Type: application/json; charset=utf-8
Date: Thu, 15 Dec 2016 09:52:32 GMT
{
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhY2Nlc3MiLCJpYXQiOjE0ODE3OTU1NTIsImlzcyI6InRlc3QuYnJ1bm8uZnIiLCJzdWIiOiI1MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxODUwZCIsInNjb3BlIjoiZmlsZXM6cmVhZCJ9.ctH03reuSDxF3-jCbL-63lB3CFouag8_Jd4lJTxbTY1szvrQx00WctOD6PR7o4l0OTrAz2QXUd0GlY2_OB43mQ",
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyZWZyZXNoIiwiaWF0IjoxNDgxNzk1NTUyLCJpc3MiOiJ0ZXN0LmJydW5vLmZyIiwic3ViIjoiNTFlNGUwYjM5ZTJiNThlMjJmYjdkNGE2MzQwMTg1MGQiLCJzY29wZSI6ImZpbGVzOnJlYWQifQ.ErzlUxqlk9Uo71HjTrjt0qIs766EaIBqAI51TSs15fVV3Yr8yraXfRmPtPGy8cJubIVkSPGIeJFuBaIBCwy80g",
"scope": "files:read",
"token_type": "bearer"
}
cozy@cozy-stack-v2:~$ http -v --form POST :8080/auth/access_token grant_type=refresh_token refresh_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyZWZyZXNoIiwiaWF0IjoxNDgxNzk1NTUyLCJpc3MiOiJ0ZXN0LmJydW5vLmZyIiwic3ViIjoiNTFlNGUwYjM5ZTJiNThlMjJmYjdkNGE2MzQwMTg1MGQiLCJzY29wZSI6ImZpbGVzOnJlYWQifQ.ErzlUxqlk9Uo71HjTrjt0qIs766EaIBqAI51TSs15fVV3Yr8yraXfRmPtPGy8cJubIVkSPGIeJFuBaIBCwy80g client_id=51e4e0b39e2b58e22fb7d4a63401850d client_secret=hps2RwGhNVzkEOZN-JcDRX80Xg1IFMhr scope=files:read Host:test.bruno.fr
POST /auth/access_token HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 430
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: test.bruno.fr
User-Agent: HTTPie/0.8.0
grant_type=refresh_token&refresh_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyZWZyZXNoIiwiaWF0IjoxNDgxNzk1NTUyLCJpc3MiOiJ0ZXN0LmJydW5vLmZyIiwic3ViIjoiNTFlNGUwYjM5ZTJiNThlMjJmYjdkNGE2MzQwMTg1MGQiLCJzY29wZSI6ImZpbGVzOnJlYWQifQ.ErzlUxqlk9Uo71HjTrjt0qIs766EaIBqAI51TSs15fVV3Yr8yraXfRmPtPGy8cJubIVkSPGIeJFuBaIBCwy80g&client_id=51e4e0b39e2b58e22fb7d4a63401850d&client_secret=hps2RwGhNVzkEOZN-JcDRX80Xg1IFMhr&scope=files%3Aread
HTTP/1.1 200 OK
Content-Length: 342
Content-Type: application/json; charset=utf-8
Date: Thu, 15 Dec 2016 09:54:31 GMT
{
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhY2Nlc3MiLCJpYXQiOjE0ODE3OTU2NzEsImlzcyI6InRlc3QuYnJ1bm8uZnIiLCJzdWIiOiI1MWU0ZTBiMzllMmI1OGUyMmZiN2Q0YTYzNDAxODUwZCIsInNjb3BlIjoiZmlsZXM6cmVhZCJ9.UV29FJDLU6AAKzz-2WmV7YLWW-Mho2r-kqScNjF2hueB70f8FdwNp89hRPLDp4JAT3XpFaxDFnp4UyHvgQLFQg",
"scope": "files:read",
"token_type": "bearer"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment