Skip to content

Commit 2958ad6

Browse files
committed
Add documentation for two factor authentication
1 parent fa6c785 commit 2958ad6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/two_factor_authentication.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Two factor authentication
2+
[Back to the navigation](index.md)
3+
4+
5+
### Raising the exception
6+
7+
```php
8+
try {
9+
$authorization = $github->api('authorizations')->create();
10+
} catch (Github\Exception\TwoFactorAuthenticationRequiredException $e {
11+
echo sprintf("Two factor authentication of type %s is required.", $e->getType());
12+
}
13+
```
14+
15+
Once the code has been retrieved (by sms for example), you can create an authorization:
16+
17+
```
18+
$authorization = $github->api('authorizations')->create(array('note' => 'Optional'), $code);
19+
```

0 commit comments

Comments
 (0)