Completed
Push — master ( a054a0...cffdc3 )
by Johnny
02:13
created

Auth::requestAccessToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 17
cp 0
rs 9.4286
cc 1
eloc 14
nc 1
nop 2
crap 2
1
<?php
2
namespace Redbox\Twitch\Resource;
3
use Redbox\Twitch;
4
5
class Auth extends ResourceAbstract {
6
7
    public function requestAccessToken($code = '', $state = '')
8
    {
9
10
        $body = array(
11
            'client_id'     => $this->getClient()->getClientId(),
12
            'client_secret' => $this->getClient()->getClientSecret(),
13
            'grant_type'    => 'authorization_code',
14
            'redirect_uri'  => $this->getClient()->getRedirectUri(),
15
            'code'          => $code,
16
            'state'         => $state,
17
        );
18
19
        $response = $this->call('requestAccessToken', array(), $body);
20
21
        $accesstoken = new Twitch\AccessToken;
22
        $accesstoken->setAccessToken($response->access_token);
23
        $accesstoken->setRefreshToken($response->refresh_token);
24
        $accesstoken->setScope($response->scope);
25
        return $accesstoken;
26
    }
27
}