Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92848834
PhutilAuthAdapterOAuthTwitch.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 24, 05:08
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Nov 26, 05:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22524999
Attached To
rPHU libphutil
PhutilAuthAdapterOAuthTwitch.php
View Options
<?php
/**
* Authentication adapter for Twitch.tv OAuth2.
*/
final
class
PhutilAuthAdapterOAuthTwitch
extends
PhutilAuthAdapterOAuth
{
public
function
getAdapterType
()
{
return
'twitch'
;
}
public
function
getAdapterDomain
()
{
return
'twitch.tv'
;
}
public
function
getAccountID
()
{
return
$this
->
getOAuthAccountData
(
'_id'
);
}
public
function
getAccountEmail
()
{
return
$this
->
getOAuthAccountData
(
'email'
);
}
public
function
getAccountName
()
{
return
$this
->
getOAuthAccountData
(
'name'
);
}
public
function
getAccountImageURI
()
{
return
$this
->
getOAuthAccountData
(
'logo'
);
}
public
function
getAccountURI
()
{
$name
=
$this
->
getAccountName
();
if
(
$name
)
{
return
'http://www.twitch.tv/'
.
$name
;
}
return
null
;
}
public
function
getAccountRealName
()
{
return
$this
->
getOAuthAccountData
(
'display_name'
);
}
protected
function
getAuthenticateBaseURI
()
{
return
'https://api.twitch.tv/kraken/oauth2/authorize'
;
}
protected
function
getTokenBaseURI
()
{
return
'https://api.twitch.tv/kraken/oauth2/token'
;
}
public
function
getScope
()
{
return
'user_read'
;
}
public
function
getExtraAuthenticateParameters
()
{
return
array
(
'response_type'
=>
'code'
,
);
}
public
function
getExtraTokenParameters
()
{
return
array
(
'grant_type'
=>
'authorization_code'
,
);
}
protected
function
loadOAuthAccountData
()
{
return
id
(
new
PhutilTwitchFuture
())
->
setClientID
(
$this
->
getClientID
())
->
setAccessToken
(
$this
->
getAccessToken
())
->
setRawTwitchQuery
(
'user'
)
->
resolve
();
}
}
Event Timeline
Log In to Comment