Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Problems getting access_token

A topic by James created Jul 24, 2023 Views: 490 Replies: 8
Viewing posts 1 to 4

I'm trying to use the following to get an access token for a browser game I'm working on:

var queryString = window.location.hash.slice(1); 
var params = new URLSearchParams(queryString); 
var accessToken = params.get("access_token");

The problem is the queryString and params are empty and the accessToken is null. Is there something I need to set up before I use this code?

Are you trying to get an access token within the Itch app or on the website? I don't think you can use the OAuth method in the app, and on the website you can't get a token for your HTML5 game directly, unless you redirect/open a new page to your OAuth URL and then redirect back to your game.

I tried that but I get the following error:

Refused to display 'https://itch.io/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

You might be able to get it to open in a new tab/window, but returning the token to your game gets more complicated. In short Itch doesn't provide a way for web games to identify users and they don't seem to be interested in adding this.

(1 edit)

Too bad. But if they don't want to provide oauth, they should take down the documentation. It's misleading.

OAuth does work but mainly for a narrow use case.

Really? How can you use it?

(1 edit)

As described here, but again, it's not meant to be used in the Itch app.

(1 edit)

Oh yeah. But what I want to do is identify a user and let them increase their score, like in a real game. I guess itch is not the platform for that.