Code Monkey home page Code Monkey logo

Comments (9)

bozzit avatar bozzit commented on May 28, 2024 3

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.

  1. From the PSN Website or App or Console Enable 2 Step Verification
  2. 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
  3. 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);
  1. Save the refresh and npsso values from the output

  2. 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.

dandelaney8 avatar dandelaney8 commented on May 28, 2024 2

@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.

Tustin avatar Tustin commented on May 28, 2024

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.

expressgts18 avatar expressgts18 commented on May 28, 2024

@bozzit @Tustin same issue as @dandelaney8 is facing..

from psn-php.

markl181 avatar markl181 commented on May 28, 2024

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.

bozzit avatar bozzit commented on May 28, 2024

@markl181 @expressgts18

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.

markl181 avatar markl181 commented on May 28, 2024

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.

bozzit avatar bozzit commented on May 28, 2024

@markl181

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.

markl181 avatar markl181 commented on May 28, 2024

@bozzit perfect, looks like it works now. Thanks!

from psn-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.