Hello,
I’ve got a Steam page for my game and I’ve put in the web API and AppID in the project settings, and the AppID in the steam AppID text file (and yes I’ve quadruple checked) but when I use the code I got from the documentation I get an invalid token error. I have a SteamManager in my scene which I got from Steamworks.net that calls the Steam Init function. I’ve been stuck on this for several days and none of the solutions I’ve found online have worked. It doesn’t work in the editor play mode or in the build and I’m using Steamworks.net for my Steam integration. Also I’ve just got this script on an empty game object in my menu scene. I’m also a little confused about beginning and ending an auth session and I’ve struggled to find much about that online. Any help is very much appreciated, thank you!
Here is my code:
using Steamworks;
using System;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Core;
public class SteamAuth : MonoBehaviour
{
Callback<GetAuthSessionTicketResponse_t> m_AuthTicketResponseCallback;
HAuthTicket m_AuthTicket;
string m_SessionTicket;
void Awake()
{
SignInWithSteam();
}
void SignInWithSteam()
{
// It's not necessary to add event handlers if they are
// already hooked up.
// Callback.Create return value must be assigned to a
// member variable to prevent the GC from cleaning it up.
// Create the callback to receive events when the session ticket
// is ready to use in the web API.
// See GetAuthSessionTicket document for details.
m_AuthTicketResponseCallback = Callback<GetAuthSessionTicketResponse_t>.Create(OnAuthCallback);
var buffer = new byte[1024];
m_AuthTicket = SteamUser.GetAuthSessionTicket(buffer, buffer.Length, out var ticketSize);
Array.Resize(ref buffer, (int)ticketSize);
// The ticket is not ready yet, wait for OnAuthCallback.
m_SessionTicket = BitConverter.ToString(buffer).Replace("-", string.Empty);
}
async void OnAuthCallback(GetAuthSessionTicketResponse_t callback)
{
// Call Unity Authentication SDK to sign in or link with Steam.
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInWithSteamAsync(m_SessionTicket);
Debug.Log("Steam Login success. Session Ticket: " + m_SessionTicket);
}
}
I’m getting these errors:
WebRequestException: {“title”:“PERMISSION_DENIED”,“detail”:“invalid token”,“details”:[ ],“status”:401}
[Authentication]: Request completed with error: {“title”:“PERMISSION_DENIED”,“detail”:“invalid token”,“details”:[ ],“status”:401}
[Authentication]: Request failed: 401, {“title”:“PERMISSION_DENIED”,“detail”:“invalid token”,“details”:[ ],“status”:401}