gogog
Low level helpers to get GOG.com website data:
- Implementation of the website authentication flow, including 2FA. Captcha is detected, not
supported.
- URLs to get various GOG.com data.
- Data types: Products, Details, Wishlist, etc. to Unmarshal responses from the URLs above.
Exported functions:
- Login - implements authentication flow for a given username, password and a callback to get second
factor auth token (you'll get this in mail on login attempt if you have it set up)
- LoggedIn - returns whether a user is logged in.
Persistent authentication
You'll need to pass http.Client reference with a cookieJar that would hold GOG.com authentication
cookies. Client implementations might differ, however general flow should look something like the
following:
- Load persistent cookies
- Create a http.CookieJar and add those cookies
- Create a http.Client with that cookieJar
- Check if the gogauth.LoggedIn is true
- If it is: interact with AccountProducts, Wishlist, etc. types that require authentication
- If it isn't: Login with a username, password, optional 2FA
- At the end of the session - save persistent cookies from the cookieJar
gogauthurls provides URL funcs for gogauth, there really isn't much value for clients to use those:
- AuthHost - used by gogauth.Login
- LoginHost - used by gogauth.Login
- AddAuthHostDefaultHeaders - used by gogauth.Login
- AddLoginHostDefaultHeaders - used by gogauth.Login
- LoginData - used by gogauth.Login
- LoginCheck - used by gogauth.Login
- OnLoginSuccess - used by gogauth.Login
- ReCaptcha - used by gogauth.Login
- LoginTwoStep - used by gogauth.Login
- UserData - used by gogauth.LoggedIn
gogog intentionally scopes the interface with GOG.com to URLs for the following reasons:
- URLs is a lightweight abstraction of a remote data interfaces and should be easier to maintain
longer term as the site updates (unless there is a public documented and well-supported API!)
- Other client implementations might differ from vangogh (gogog first consumer) and I wanted to
avoid Unmarshal costs if the clients would then want to Marshal back
- gogtypes provides all the actual types client needs to use to work with the data
Here are the key URLs functions exported by gogurls intended for client use:
AccountProductsPage
- page
- media - gogtypes.Game, gogtypes.Movie
- sortBy - see gogtypes.AccountProductsSortOrder
- updated - return just the updated
- hidden - include items hidden by the user
Details
- ID
- media - gogtypes.Game, gogtypes.Movie
ProductsPage
- page
- media - gogtypes.Game, gogtypes.Movie
- sortOrder - see gogtypes.ProductsSortOrder
WishlistPage
- page
- media - gogtypes.Game, gogtypes.Movie
- sortOrder - see gogtypes.WishlistSortOrder
- hidden - include items hidden by the user
Main data types exported by gogtypes:
- AccountProduct - type of individual products from the AccountProductsPage
- AccountProductsPage - type of a gogurls.AccountProductsPage JSON response
- Details - type of a gogurls.Details JSON response
- Product - type of individual products from the ProductsPage
- ProductsPage - type of a gogurls.ProductsPage JSON response
- WishlistPage - type of a gogurls.WishlistPage JSON response