[editor] Auth to OSM via a browser always

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-05-23 14:31:58 +07:00
parent c4ca4c907b
commit 3032eb6dfe
3 changed files with 11 additions and 10 deletions

View File

@@ -58,20 +58,20 @@ public class OsmLoginFragment extends BaseMwmToolbarFragment
mProgress = view.findViewById(R.id.osm_login_progress); mProgress = view.findViewById(R.id.osm_login_progress);
final String dataVersion = DateUtils.getShortDateFormatter().format(Framework.getDataVersion()); final String dataVersion = DateUtils.getShortDateFormatter().format(Framework.getDataVersion());
if (BuildConfig.FLAVOR.equals("google")) // TODO(@pastk): remove unused flow with users entering credentials into app's form
{
// Hide login and password inputs and Forgot password button // Hide login and password inputs and Forgot password button
UiUtils.hide(view.findViewById(R.id.osm_username_container), UiUtils.hide(view.findViewById(R.id.osm_username_container),
view.findViewById(R.id.osm_password_container), view.findViewById(R.id.osm_password_container),
mLostPasswordButton); mLostPasswordButton);
mLoginButton.setOnClickListener((v) -> loginWithBrowser()); mLoginButton.setOnClickListener((v) -> loginWithBrowser());
} /* login via in-app form
else else
{ {
mLoginButton.setOnClickListener((v) -> login()); mLoginButton.setOnClickListener((v) -> login());
mLostPasswordButton.setOnClickListener((v) -> Utils.openUrl(requireActivity(), Constants.Url.OSM_RECOVER_PASSWORD)); mLostPasswordButton.setOnClickListener((v) -> Utils.openUrl(requireActivity(), Constants.Url.OSM_RECOVER_PASSWORD));
} }
*/
String code = readOAuth2CodeFromArguments(); String code = readOAuth2CodeFromArguments();
if (code != null && !code.isEmpty()) if (code != null && !code.isEmpty())

View File

@@ -289,11 +289,12 @@ string OsmOAuth::BuildOAuth2Url() const
string OsmOAuth::FinishAuthorization(string const & oauth2code) const string OsmOAuth::FinishAuthorization(string const & oauth2code) const
{ {
/// @todo(pastk): remove client_secret everywhere, its not required for auth through non-confidential apps
auto params = BuildPostRequest({ auto params = BuildPostRequest({
{"grant_type", "authorization_code"}, {"grant_type", "authorization_code"},
{"code", oauth2code}, {"code", oauth2code},
{"client_id", m_oauth2params.m_clientId}, {"client_id", m_oauth2params.m_clientId},
{"client_secret", m_oauth2params.m_clientSecret}, //{"client_secret", m_oauth2params.m_clientSecret},
{"redirect_uri", m_oauth2params.m_redirectUri}, {"redirect_uri", m_oauth2params.m_redirectUri},
{"scope", m_oauth2params.m_scope}, {"scope", m_oauth2params.m_scope},
}); });

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#define OSM_OAUTH2_CLIENT_ID "P10w0BFkJ2-IoV2tg94biU-x9grsbGnw072Ud-kMcUc" #define OSM_OAUTH2_CLIENT_ID "P10w0BFkJ2-IoV2tg94biU-x9grsbGnw072Ud-kMcUc"
#define OSM_OAUTH2_CLIENT_SECRET "3l3AjaFW7sJRKM4sOF0MrdBEpbm5XjCeCFDULFfu8vY" #define OSM_OAUTH2_CLIENT_SECRET ""
#define OSM_OAUTH2_REDIRECT_URI "cm://oauth2/osm/callback" #define OSM_OAUTH2_REDIRECT_URI "cm://oauth2/osm/callback"
#define OSM_OAUTH2_SCOPE "read_prefs write_api write_notes" #define OSM_OAUTH2_SCOPE "read_prefs write_api write_notes"
#define MWM_GEOLOCATION_SERVER "" #define MWM_GEOLOCATION_SERVER ""