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

Auth   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 23
ccs 0
cts 17
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A requestAccessToken() 0 20 1
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
}