shr3jn / fastlane-plugin-huawei_appgallery_connect

Fastlane plugin to upload android apps to Huawei AppGallery Connect
MIT License
85 stars 21 forks source link

[AppGalleryConnectFileService]distContryList is empty and usage route site is not China.] #66

Closed dzengi-com closed 3 months ago

dzengi-com commented 3 months ago
huawei_appgallery_connect(
    client_id: client_id,
    client_secret: client_secret,
    app_id: app_id,
    apk_path: File.join(Dir.pwd, "../android/app/build/outputs/bundle/release", "app-release.aab"),

    is_aab: true,
    submit_for_review: true,
    delay_before_submit_for_review: 60,
)

{"ret":{"code":204144694,"msg":"[cfs] get siteId failed, additional msg is [[AppGalleryConnectFileService]distContryList is empty and usage route site is not China.]"}}

I found the issue, and in my account I selected all (199) countries except China. But I still get this error

shr3jn commented 3 months ago

Hi @dzengi-com, this error you're receiving is from AGC so you may get solution if you post this on AGC community.

https://forums.developer.huawei.com/forumPortal/en/forum/events

dzengi-com commented 3 months ago

@shr3jn Yes, and I received an answer from one of the developers that I should pass a list of countries and this needs to be implemented in the plugin. What do you think?

shr3jn commented 3 months ago

@dzengi-com on which API should the country list be passed?

dzengi-com commented 3 months ago

Well, apparently in one of the APIs that uses this plugin

shr3jn commented 3 months ago

Please provide link to your post on AGC forum.

dzengi-com commented 3 months ago

I don't have a link, it was a private conversation

shr3jn commented 3 months ago

If you have a link to the documentation on which API should the country param be passed, let me know.

dzengi-com commented 3 months ago

Could you share api calls which does this plugin use?

arnovanzyl commented 2 months ago

I'm also running into the same issue here :/

[!] {"ret":{"code":204144694,"msg":"[cfs] get siteId failed, additional msg is [[AppGalleryConnectFileService]distContryList is empty and usage route site is not China.]"}}

arnovanzyl commented 2 months ago

Did someone manage to solve this?

dzengi-com commented 2 months ago

@shr3jn Why did you close this issue? It is relevant and 100% reproducible

shr3jn commented 2 months ago

okay i will check once.

famasf1 commented 2 months ago

I don't have a link, it was a private conversation

Can you ask them which API they are talking about specifically? I forked the repo and tried adding 'publishCountry' from this Publishing API but had no luck. And i couldn't find any reference about adding countries anywhere else.

dzengi-com commented 2 months ago

I don't have a link, it was a private conversation

Can you ask them which API they are talking about specifically? I forked the repo and tried adding 'publishCountry' from this Publishing API but had no luck. And i couldn't find any reference about adding countries anywhere else.

I haven't looked into exactly what methods this plugin calls. Since they are falling, it means that countries also need to be added to parameters

famasf1 commented 2 months ago

I don't have a link, it was a private conversation

Can you ask them which API they are talking about specifically? I forked the repo and tried adding 'publishCountry' from this Publishing API but had no luck. And i couldn't find any reference about adding countries anywhere else.

I haven't looked into exactly what methods this plugin calls. Since they are falling, it means that countries also need to be added to parameters

i assume this plugin use publishing API since it had parameter for privacy_policy_url and it's the only API i found that have anything related to country. So i forked this repo and put in a new parameter inside and attempted to run CI with my own app.

I added the following line into huawei_appgallery_connect_action.rb

this is inside self.run

if params[:privacy_policy_url] != nil
            if params[:publish_country] != nil
              Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url], params[:publish_country])
            else
              Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url], 'US, OTHER') #according to docs, OTHER cannot be the only parameter. Default to US.
            end
          end

this is inside self.available_options

FastlaneCore::ConfigItem.new(key: :publish_country,
                                                  env_name: "HUAWEI_APPGALLERY_PUBLISH_COUNTRY",
                                                  description: "Country code for the country where the app is published",
                                                  optional: true,
                                                  type: String)

then add a new parameter and editing json encoding inside huawei_appgallery_connect_helper.rb

def self.update_appinfo(client_id, token, app_id, privacy_policy_url, publish_country)
        UI.important("Updating app info")

        uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/app-info?appId=#{app_id}")

        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true
        request = Net::HTTP::Put.new(uri.request_uri)
        request["client_id"] = client_id
        request["Authorization"] = "Bearer #{token}"
        request["Content-Type"] = "application/json"

        request.body = {privacyPolicy: privacy_policy_url, publishCountry: publish_country}.to_json

        response = http.request(request)
        if !response.kind_of? Net::HTTPSuccess
          UI.user_error!("Cannot update app info, please check API Token / Permissions (status code: #{response.code})")
          return false
        end
        result_json = JSON.parse(response.body)

        if result_json['ret']['code'] == 0
          UI.success("Successfully updated app info")
        else
          UI.user_error!(result_json)
          UI.user_error!("Failed to update app info")
        end
      end

And yes, i edited Pluginfile to manually linked to my own fork.

gem 'fastlane-plugin-huawei_appgallery_connect', :git => 'https://github.com/famasf1/fastlane-plugin-huawei_appgallery_connect', :branch => 'master'

I'm not sure if i edited the wrong methods because i still got the same error. Feel free to dive into my fork here. That's why i want to know specifically which API did the Huawei developer is talking about.

dzengi-com commented 1 month ago

Did someone manage to solve this?

No. This issue is still relevant. The library has not been updated since May