fastlane/itc-api-docs

Can't login

omidahourai opened this issue · 11 comments

Played with the options in Paw for an hour. I tried deleting the cookies as suggested, but it still returns 200 without logging in. Not sure what's going on. Response i'm getting:

image

Figured it out (via view-source) - Your request address is outdated. Use /WebObjects/iTunesConnect.woa/wo/7.0.1.13.3.15.2.1.1.3.1.1

Uh, that's not good. I'll have to find a way to fetch the latest URL for authentication. Do you have an idea how to solve this?

No clue, and probably apple doesn't want you to know how ;-) But maybe just add a note in the docs to check the iTunesConnect login page source for the latest url.

I'm trying to figure out a way to deal with this right now too... I think for you, a possible solution is web scraping + github's api to automatically update the docs with any changes to the endpoint

@keithblaha I like the idea of automatically updating the login URL on GitHub. Web Scraping of this URL is super simple and probably just one line of Ruby.

I'll temporary update the URL for now and will work on a better long term solution.

The login url, which you use to send POST requests to is (I assume) different for every session and should be different for every user. In order to get this address, you need to parse server page form, indeed: https://github.com/kovpas/itc.cli/blob/archive/itc/core/server.py#L72

@kovpas It shouldn't be different for every user. I used the same login URL for about a week and it working fine.

@KrauseFx might be a session with a certain expiration period then, so URL is invalid after this period passed.

@KrauseFx Just a shot in the blue: Afaik the cookies are cross service, so you might be able to authenticate with for example https://idmsa.apple.com/IDMSWebAuth/authenticate and use the cookie from there.

I didn't try this though.

@kommen That's a good idea, I actually have the code from the spaceship already:

URL_AUTHENTICATE = "https://idmsa.apple.com/IDMSWebAuth/authenticate" # Mixed - Dev Portal
     login_request = Excon.post(URL_AUTHENTICATE, 
        body: URI.encode_www_form(
          appleId: user,
          accountPassword: password,
          appIdKey: api_key
        ),
        headers: { 
          "Content-Type" => "application/x-www-form-urlencoded" 
        }
      )

The problem here is the api_key. It is static and built in into Xcode, but we're probably not allowed to use it. I found a nice workaround for spaceship though, which involves some Ruby scripting.

I added new information about the login URL: https://github.com/fastlane/itc-api-docs#login

Not 100% perfect yet, but you now have a very simple script that prints out the current URL 👍