credentials = ServiceAccountCredentials.from_json_keyfile_name(CRED,
['https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive',"https://www.googleapis.com/auth/script.external_request",
'https://www.googleapis.com/auth/script.scriptapp', 'https://www.googleapis.com/auth/drive.scripts'])
httpAuth = credentials.authorize(httplib2.Http())
servise = apiclient.discovery.build('sheets', 'v4', http=httpAuth)
service = build('script', 'v1', credentials=credentials)
script_id = 'он есть'
request = {"function": "give_bot"}
response = service.scripts().run(scriptId=script_id, body=request).execute()
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_info);
textfield = findViewById(R.id.textfield);
button = findViewById(R.id.button);
info = findViewById(R.id.info);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(textfield.getText().toString().trim().equals(""))
Toast.makeText(PlayerInfoActivity.this, R.string.no_nick, Toast.LENGTH_LONG).show();
else {
String url = "http://creeparealms.dmistas.beget.tech/app/players.json";
new GetURLData().execute(url);
}
}
});
}
private class GetURLData extends AsyncTask<String, String, String> {
protected void onPreExecute() {
super.onPreExecute();
info.setText("Обработка...");
}
@Override
protected String doInBackground(String... strings) {
HttpURLConnection connection = null;
BufferedReader reader = null;
try{
URL url = new URL(strings[0]);
connection = (HttpURLConnection) url.openConnection();
connection.connect();
InputStream stream = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(stream));
StringBuffer buffer = new StringBuffer();
String line = "";
while((line = reader.readLine()) != null)
buffer.append(line).append("\n");
return buffer.toString();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (connection !=null)
connection.disconnect();
if (reader !=null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
@SuppressLint("SetTextI18n")
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
String nick = textfield.getText().toString();
try {
JSONObject jsonObject = new JSONObject(result);
JSONObject jsonInfo = (JSONObject) jsonObject.getJSONObject("players").getJSONObject("playerInfo").getJSONObject(nick);
info.setText(nick + "\nВ вк: "
+ jsonInfo.getString("VK") + "\nСервер: " + jsonInfo.getString("Server") + "\n" + jsonInfo.getString("Season") + "\nИграет? - " +
jsonInfo.getString("Play") + "\nРейтинг игрока: " + jsonInfo.getString("Rating") + "\nО игроке: " + jsonInfo.getString("About"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void openMain(View v) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
if(FirebaseAuth.getInstance().getCurrentUser() == null)
startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().build(), SIGN_IN_CODE);
else {
Snackbar.make(activity_main, "Вы авторизованы", Snackbar.LENGTH_LONG).show();
displayAllMessages();
}
Но тогда как password_verify это поймёт?