Comments (9)
If you read all the posts in #50 Invalid token, the issue is the new reCaptcha that Sony is now enforcing. There is no way to do this authentication via the Script at this time. So we have worked around the authentication issue by doing the following.
- From the PSN Website or App or Console Enable 2 Step Verification
- Go to https://auth.api.sonyentertainmentnetwork.com/login.jsp
Enter your credentials, Solve the reCaptcha, and when you get the ENTER Verification Code screen take a look at the URL in your browser. Collect the following ID: ticket_uuid=b7aeb485-xxxx-4ec2-zzzz-0f23bcee5bc5&layout_type=...... DO NOT ENTER THE VERIFICATION CODE - From the API
try
{
$account = new \PSN\Auth('[email protected]',
'YOURPASS',
'b7aeb485-xxxx-4ec2-zzzz-0f23bcee5bc5',
'verification_code_you_got_on_your_phone');
}
catch (\PSN\AuthException $e)
{
print $e->GetError();
exit;
}
$tokens = $account->GetTokens();
print_r($tokens);
-
Save the refresh and npsso values from the output
-
From now on you can authenticate (Refresh your tokens) instead of re-authenticating every time.
Like this.
$tokens = \PSN\Auth::GrabNewTokens('REFRESH_VALUE_SAVED_ABOVE');
$tokens['npsso'] = 'NPSSO_VALUE_SAVED_ABOVE';
$friends = new \PSN\Friend($tokens);
$my_friends = $friends->MyFriends();
print_r($my_friends);
$token should now allow you to get your Friends list, messages, Friends etc,
Hope this helps.
from psn-php.
@bozzit & @Tustin hey, thanks for getting this stuff together.
I just tried the method above, and after logging in on https://auth.api.sonyentertainmentnetwork.com/login.jsp with my account that has 2FA enabled, I'm not getting redirected anywhere. All I get is an error saying "Incorrect e-mail address or password. Please try again."
I tried this earlier with the account before I enabled 2FA, and it logged me in and brought me to the API page with a title, an option to log out, and not much else. Did they change something since you tried this? If I can't get that ticket_uuid I assume this won't work for me.
Thanks!
Dan
from psn-php.
I looked at one of those apps you mentioned and it seems like they use the method I wanted to try (showing the login form on Sony's site and then redirecting back) but for some reason, they're allowed to the redirect to return to their app after the login. I tried replicating it with this to allow you to specify a callback URL as the redirect URL for Sony's site but they have checks in place to make sure the URL is registered with the client_id used with the request. I don't really have a solution for getting it to work like that at the moment.
from psn-php.
@bozzit @Tustin same issue as @dandelaney8 is facing..
from psn-php.
Also same - just coming back to this after a while and still unable to make this work unfortunately. When I try the url above I get an error and directed back to https://auth.api.sonyentertainmentnetwork.com/login.jsp?authentication_error=true&error_code=4902
I am able to sign in with the same credentials through https://id.sonyentertainmentnetwork.com/ but that never shows any uuid during the signin process
from psn-php.
Start Here instead. https://www.bungie.net/en/User/SignIn/Psnid?code=000000
That will redirect you to the correct PSN url where you should be able to get the Token.
If you have linked a bungie account before, click Not You link
Let me know
from psn-php.
thanks @bozzit - I got a little closer, I was able to get the refresh token but now I get an error at the next step. Here's my code (with all the actual tokens etc. removed)
`try
{
$account = new \PSN\Auth("[email protected]", 'password');
}
catch (\PSN\AuthException $e)
{
header("Content-Type: application/json");
die($e->GetError());
}
$tokens = \PSN\Auth::GrabNewTokens('refreshtoken');
$tokens['npsso'] = 'npsso';
`
The error I get is
{"error":"invalid_token","error_description":"Invalid token","error_code":4097,"docs":"https://auth.api.sonyentertainmentnetwork.com/docs/","parameters":["captchatokenmissing"]}
from psn-php.
The issue is that you should NOT Auth once your have refresh tokens... but just Get New tokens instead.
I use a mysql DB to store the refresh tokens I manually got from the bungie URL and update them with the results of GrabNewTokens.
My code looks something like:
//****************************************************
// Retrieve refresh and npsso saved to your database
//****************************************************
$cDB = new mysqli(db_host, db_user, db_passwd, db_name);
$result = $cDB->query('SELECT * from psn_oauth_data"));
$row = $result->fetch_assoc();
$tokens = \PSN\Auth::GrabNewTokens($row['refresh']);
$tokens['npsso'] = $row['npsso'];
//****************************************************
// SAVE new refresh token back to the database
//****************************************************
$sSQL = sprintf('UPDATE psn_oauth_data SET oauth = \'%s\', refresh = \'%s\' WHERE token_id =1', $tokens['oauth'], $tokens['refresh']);
$rUpdateResultSet = $cDB->Execute($sSQL);
//****************************************************
// Do your PSN-PHP things using the new Tokens
//****************************************************
$messaging = new \PSN\Messaging($tokens);
.
.
.
from psn-php.
@bozzit perfect, looks like it works now. Thanks!
from psn-php.
Related Issues (20)
- Fatal error on a psnId for just 1 game HOT 1
- When getting the definedTrophies for trophyGroup, it will get the definedTrophies for the entire game HOT 2
- Problem when getting platform of trophy after update HOT 4
- Client does not have grant type: 'authorization_code' HOT 39
- Trophy::earned returns null HOT 6
- Change in : foreach ($trophyTitle->platform () as $platform) HOT 5
- PlayTime aren't updated anymore HOT 5
- Performance issues with latest version? HOT 2
- Offset 128 does not exist HOT 2
- How to alter the language / localization of games and trophies? HOT 6
- isOnline doesn't work HOT 6
- Check if a title_id is a game HOT 2
- All trophies to all games HOT 2
- Doubts about token expiration time HOT 2
- How Can I Show Every AccountId Searched? HOT 15
- Can't login with refresh token. Only with NPSSO HOT 1
- Trophy EarnedDateTime and Progress can't be retrieved at the same time HOT 3
- Fatal error using $query = $client->users()->search($id); Offset 128
- problem with $client->loginWithNpsso HOT 1
- Trophy Earned Rate Not Working Anymore? HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psn-php.