private void OutputAuthCode(Sony.NP.Auth.AuthCodeResponse response) { if (response == null) { return; } PrintLog("Auth Code Response"); if (response.Locked == false) { PrintLog("AuthCode : " + response.AuthCode); PrintLog("IssuerId : " + response.IssuerId); var user = AccelBytePlugin.GetUser(); PrintLog("\nLogin to AB"); user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result => { if (!result.IsError) { PrintLog("\nLogin Success!"); user.GetData(resultData => { if (!resultData.IsError) { PrintLog("\nUserId: " + resultData.Value.userId); PrintLog("\nDisplayName: " + resultData.Value.displayName); } }); } }); } }
void SignIn() { try { Sony.NP.Auth.GetAuthCodeRequest request = new Sony.NP.Auth.GetAuthCodeRequest(); // test values from SDK nptoolkit sample ... replace with your own project values Sony.NP.Auth.NpClientId clientId = new Sony.NP.Auth.NpClientId(); clientId.Id = ""; request.ClientId = clientId; request.Scope = "psn:s2s"; request.UserId = GetLocalProfiles(); PrintLog("\nGet UserId Success! UserId: " + request.UserId); Sony.NP.Auth.AuthCodeResponse response = new Sony.NP.Auth.AuthCodeResponse(); int requestId = Sony.NP.Auth.GetAuthCode(request, response); while (response.Locked) { new WaitForSeconds(1); } PrintLog("\n Return Code: " + response.ReturnCode); PrintLog("\nIssuerId: " + response.IssuerId); if (!response.IsErrorCode) { PrintLog("\nAuthCode: " + response.AuthCode); var user = AccelBytePlugin.GetUser(); PrintLog("\nLogin to AB"); user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.PS4, response.AuthCode, result => { if (!result.IsError) { PrintLog("\nLogin Success!"); user.GetData(resultData => { if (!resultData.IsError) { PrintLog("\nUserId: " + resultData.Value.userId); PrintLog("\nDisplayName: " + resultData.Value.displayName); } }); } }); } } catch (Sony.NP.NpToolkitException e) { PrintLog("\nException : " + e.ExtendedMessage); } }