Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Törcsvári Gergő
AuthSCH - Client
Commits
a5610610
Commit
a5610610
authored
Jul 17, 2014
by
Zoltán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refresh token segitsegevel access token frissitese
parent
db8593e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
php/AuthSCHClient.class.php
php/AuthSCHClient.class.php
+16
-0
No files found.
php/AuthSCHClient.class.php
View file @
a5610610
...
...
@@ -30,6 +30,8 @@ class AuthSCHClient {
}
else
{
// load tokendata from session
$this
->
tokens
=
unserialize
(
$_SESSION
[
'tokens'
]);
if
(
$this
->
tokens
->
lastUpdate
+
3600
<
time
())
$this
->
reauthenticate
();
}
}
else
{
$this
->
tokens
=
$tokens
;
...
...
@@ -96,6 +98,20 @@ class AuthSCHClient {
}
private
function
reauthenticate
()
{
$data
=
array
(
'grant_type'
=>
'refresh_token'
,
'refresh_token'
=>
$this
->
tokens
->
refresh_token
,
);
$ch
=
$this
->
curlExec
(
"oauth2/token"
,
$data
);
$response
=
json_decode
(
$ch
);
if
(
$tokens
===
null
||
!
isset
(
$tokens
->
access_token
)
||
empty
(
$tokens
->
access_token
))
throw
new
Exception
(
"invalid token data"
);
$this
->
tokens
->
access_token
=
$tokens
->
access_token
;
}
public
function
getData
()
{
return
json_decode
(
file_get_contents
(
self
::
$host
.
'api/profile/?access_token='
.
$this
->
tokens
->
access_token
));
}
...
...
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