Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
fbce722d
Commit
fbce722d
authored
Jul 11, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Request HTTP headers argument added to `yii\authclient\BaseOAuth::api()` method
parent
fe46caf7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
30 deletions
+24
-30
BaseOAuth.php
extensions/authclient/BaseOAuth.php
+8
-4
CHANGELOG.md
extensions/authclient/CHANGELOG.md
+1
-0
OAuth1.php
extensions/authclient/OAuth1.php
+6
-11
OAuth2.php
extensions/authclient/OAuth2.php
+3
-9
LinkedIn.php
extensions/authclient/clients/LinkedIn.php
+2
-2
VKontakte.php
extensions/authclient/clients/VKontakte.php
+2
-2
YandexOAuth.php
extensions/authclient/clients/YandexOAuth.php
+2
-2
No files found.
extensions/authclient/BaseOAuth.php
View file @
fbce722d
...
...
@@ -168,15 +168,17 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
* @param string $method request type.
* @param string $url request URL.
* @param array $params request params.
* @param array $headers additional request headers.
* @return array response.
* @throws Exception on failure.
*/
protected
function
sendRequest
(
$method
,
$url
,
array
$params
=
[])
protected
function
sendRequest
(
$method
,
$url
,
array
$params
=
[]
,
array
$headers
=
[]
)
{
$curlOptions
=
$this
->
mergeCurlOptions
(
$this
->
defaultCurlOptions
(),
$this
->
getCurlOptions
(),
[
CURLOPT_HTTPHEADER
=>
$headers
,
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_URL
=>
$url
,
],
...
...
@@ -479,10 +481,11 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
* @param string $apiSubUrl API sub URL, which will be append to [[apiBaseUrl]], or absolute API URL.
* @param string $method request method.
* @param array $params request parameters.
* @param array $headers additional request headers.
* @return array API response
* @throws Exception on failure.
*/
public
function
api
(
$apiSubUrl
,
$method
=
'GET'
,
array
$params
=
[])
public
function
api
(
$apiSubUrl
,
$method
=
'GET'
,
array
$params
=
[]
,
array
$headers
=
[]
)
{
if
(
preg_match
(
'/^https?:\\/\\//is'
,
$apiSubUrl
))
{
$url
=
$apiSubUrl
;
...
...
@@ -494,7 +497,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
throw
new
Exception
(
'Invalid access token.'
);
}
return
$this
->
apiInternal
(
$accessToken
,
$url
,
$method
,
$params
);
return
$this
->
apiInternal
(
$accessToken
,
$url
,
$method
,
$params
,
$headers
);
}
/**
...
...
@@ -520,8 +523,9 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
* @param string $url absolute API URL.
* @param string $method request method.
* @param array $params request parameters.
* @param array $headers additional request headers.
* @return array API response.
* @throws Exception on failure.
*/
abstract
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
);
abstract
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
);
}
extensions/authclient/CHANGELOG.md
View file @
fbce722d
...
...
@@ -6,6 +6,7 @@ Yii Framework 2 authclient extension Change Log
-
Bug #3633: OpenId return URL comparison advanced to prevent url encode problem (klimov-paul)
-
Enh #3416: VKontakte OAuth support added (klimov-paul)
-
Enh #4076: Request HTTP headers argument added to
`yii\authclient\BaseOAuth::api()`
method (klimov-paul)
-
Enh #4139: User attributes requesting at GoogleOAuth switched to Google+ API (klimov-paul)
...
...
extensions/authclient/OAuth1.php
View file @
fbce722d
...
...
@@ -151,14 +151,15 @@ class OAuth1 extends BaseOAuth
* @param string $method request type.
* @param string $url request URL.
* @param array $params request params.
* @param array $headers additional request headers.
* @return array response.
*/
protected
function
sendSignedRequest
(
$method
,
$url
,
array
$params
=
[])
protected
function
sendSignedRequest
(
$method
,
$url
,
array
$params
=
[]
,
array
$headers
=
[]
)
{
$params
=
array_merge
(
$params
,
$this
->
generateCommonRequestParams
());
$params
=
$this
->
signRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
,
$headers
);
}
/**
...
...
@@ -206,19 +207,13 @@ class OAuth1 extends BaseOAuth
}
/**
* Performs request to the OAuth API.
* @param OAuthToken $accessToken actual access token.
* @param string $url absolute API URL.
* @param string $method request method.
* @param array $params request parameters.
* @return array API response.
* @throws Exception on failure.
* @inheritdoc
*/
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
)
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
)
{
$params
[
'oauth_consumer_key'
]
=
$this
->
consumerKey
;
$params
[
'oauth_token'
]
=
$accessToken
->
getToken
();
$response
=
$this
->
sendSignedRequest
(
$method
,
$url
,
$params
);
$response
=
$this
->
sendSignedRequest
(
$method
,
$url
,
$params
,
$headers
);
return
$response
;
}
...
...
extensions/authclient/OAuth2.php
View file @
fbce722d
...
...
@@ -132,19 +132,13 @@ class OAuth2 extends BaseOAuth
}
/**
* Performs request to the OAuth API.
* @param OAuthToken $accessToken actual access token.
* @param string $url absolute API URL.
* @param string $method request method.
* @param array $params request parameters.
* @return array API response.
* @throws Exception on failure.
* @inheritdoc
*/
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
)
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
)
{
$params
[
'access_token'
]
=
$accessToken
->
getToken
();
return
$this
->
sendRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
,
$headers
);
}
/**
...
...
extensions/authclient/clients/LinkedIn.php
View file @
fbce722d
...
...
@@ -128,11 +128,11 @@ class LinkedIn extends OAuth2
/**
* @inheritdoc
*/
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
)
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
)
{
$params
[
'oauth2_access_token'
]
=
$accessToken
->
getToken
();
return
$this
->
sendRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
,
$headers
);
}
/**
...
...
extensions/authclient/clients/VKontakte.php
View file @
fbce722d
...
...
@@ -80,11 +80,11 @@ class VKontakte extends OAuth2
/**
* @inheritdoc
*/
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
)
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
)
{
$params
[
'uids'
]
=
$accessToken
->
getParam
(
'user_id'
);
$params
[
'access_token'
]
=
$accessToken
->
getToken
();
return
$this
->
sendRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
,
$headers
);
}
/**
...
...
extensions/authclient/clients/YandexOAuth.php
View file @
fbce722d
...
...
@@ -64,14 +64,14 @@ class YandexOAuth extends OAuth2
/**
* @inheritdoc
*/
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
)
protected
function
apiInternal
(
$accessToken
,
$url
,
$method
,
array
$params
,
array
$headers
)
{
if
(
!
isset
(
$params
[
'format'
]))
{
$params
[
'format'
]
=
'json'
;
}
$params
[
'oauth_token'
]
=
$accessToken
->
getToken
();
return
$this
->
sendRequest
(
$method
,
$url
,
$params
);
return
$this
->
sendRequest
(
$method
,
$url
,
$params
,
$headers
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment