Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92711390
login.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
Sat, Nov 23, 00:48
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Nov 25, 00:48 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22492557
Attached To
rPH Phabricator
login.php
View Options
<?php
require
'./_shared.php'
;
// ** YOU MUST CHANGE THIS FOR THE SAMPLE APP TO WORK **
$redirect_uri
=
'http://YOUR SERVER NAME/login.php'
;
$scope
=
WePay
::
getAllScopes
();
// If we are already logged in, send the user home
if
(!
empty
(
$_SESSION
[
'wepay_access_token'
]))
{
header
(
'Location: index.php'
);
exit
;
}
// If the authentication dance returned an error, catch it to avoid a
// redirect loop. This usually indicates some sort of application issue,
// like a domain mismatch on your redirect_uri
if
(!
empty
(
$_GET
[
'error'
]))
{
echo
'Error during user authentication: '
;
echo
htmlentities
(
$_GET
[
'error_description'
]);
exit
;
}
// If we don't have a code from being redirected back here,
// send the user to WePay to grant permissions.
if
(
empty
(
$_GET
[
'code'
]))
{
$uri
=
WePay
::
getAuthorizationUri
(
$scope
,
$redirect_uri
);
header
(
"Location: $uri"
);
}
else
{
$info
=
WePay
::
getToken
(
$_GET
[
'code'
],
$redirect_uri
);
if
(
$info
)
{
// Normally you'd integrate this into your existing auth system
$_SESSION
[
'wepay_access_token'
]
=
$info
->
access_token
;
// If desired, you can also store $info->user_id somewhere
header
(
'Location: index.php'
);
}
else
{
// Unable to obtain access token
echo
'Unable to obtain access token from WePay.'
;
}
}
Event Timeline
Log In to Comment