Skip to content

Commit

Permalink
Add code verifier generator
Browse files Browse the repository at this point in the history
  • Loading branch information
wulff committed Jun 2, 2020
1 parent f8fa75b commit 9c8c950
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/mobilepay-auth
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php

use Base64Url\Base64Url;
use Informeren\OAuth2\Client\Helper\KeyHelper;
use Informeren\OAuth2\Client\Provider\MobilePay;
use Jose\Component\Core\JWK;
Expand All @@ -19,6 +20,7 @@ Available commands:
access Uses an authorization code to retrieve a access token
refresh Uses a refresh token to retrieve a access token
pem Retrieve JWK key(s) and output in PEM format
verifier Creates a code verifier string
EOT;

if ($argc < 2) {
Expand Down Expand Up @@ -128,6 +130,17 @@ $commands = [
}
}
},
'verifier' => function ($argv, $argc) use ($script) {
if ($argc > 0) {
print "Usage: $script verifier" . PHP_EOL;
exit(1);
}

// MobilePay recommends encoding a random 32-byte sequence to create a
// 43-character URL-safe string.
$bytes = random_bytes(32);
print Base64Url::encode($bytes) . PHP_EOL;
}
];

$command = array_shift($argv);
Expand Down

0 comments on commit 9c8c950

Please sign in to comment.