AuthPlayerSteam authenticates with PsyNet via Steam session ticket and returns a WebSocket connection.
(authToken string, epicAccountID string, steamAccountID string, accountName string)
| 67 | |
| 68 | // AuthPlayerSteam authenticates with PsyNet via Steam session ticket and returns a WebSocket connection. |
| 69 | func (p *PsyNet) AuthPlayerSteam(authToken string, epicAccountID string, steamAccountID string, accountName string) (*PsyNetRPC, error) { |
| 70 | localPlayerId := NewPlayerID(PlatformSteam, steamAccountID) |
| 71 | req := &AuthPlayerRequest{ |
| 72 | Platform: string(PlatformSteam), |
| 73 | PlayerName: accountName, |
| 74 | PlayerID: steamAccountID, |
| 75 | Language: "INT", |
| 76 | AuthTicket: authToken, |
| 77 | BuildRegion: "", |
| 78 | FeatureSet: p.featureSet, |
| 79 | Device: "PC", |
| 80 | SkipAuth: false, |
| 81 | SetAsPrimaryAccount: true, |
| 82 | EpicAuthTicket: authToken, |
| 83 | EpicAccountID: epicAccountID, |
| 84 | } |
| 85 | |
| 86 | var res AuthPlayerResponse |
| 87 | err := p.postJSON([]string{"Auth", "AuthPlayer", "v2"}, req, &res) |
| 88 | if err != nil { |
| 89 | return nil, fmt.Errorf("failed to authenticate player: %w", err) |
| 90 | } |
| 91 | |
| 92 | rpc, err := p.establishSocket(res.PerConURLv2, localPlayerId, res.PsyToken, res.SessionID) |
| 93 | if err != nil { |
| 94 | return nil, fmt.Errorf("failed to establish websocket: %w", err) |
| 95 | } |
| 96 | |
| 97 | go rpc.readMessages() |
| 98 | rpc.schedulePing() |
| 99 | |
| 100 | return rpc, nil |
| 101 | } |
no test coverage detected