Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/hide auth details #77

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def username = properties.getProperty("plivo.username", "") ?: "\"\""
def password = properties.getProperty("plivo.password", "") ?: "\"\""
def authID = properties.getProperty("plivo.authID", "") ?: "\"\""
def authToken = properties.getProperty("plivo.authToken", "") ?: "\"\""

android {
compileSdkVersion 30
Expand All @@ -16,6 +18,8 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "String", "Username", username
buildConfigField "String", "Password", password
buildConfigField "String", "AuthID", authID
buildConfigField "String", "AuthToken", authToken
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ private void generateToken() {
MediaType mediaType = MediaType.parse("application/json");
Log.d(TAG, "generateToken: sub: " + sub);
Log.d(TAG, "generateToken: nbf: " + nbf);
RequestBody body = RequestBody.create(mediaType, "{\n \"iss\": \"MAY2RJNZKZNJMWOTG4NT\",\n \"sub\": \"" + sub + "\",\n \"per\": {\n \"voice\": {\n \"incoming_allow\": true,\n \"outgoing_allow\": true\n }\n },\n \"exp\": " + exp + "\n}\n");
RequestBody body = RequestBody.create(mediaType, "{\n \"iss\": \""+Utils.AUTH_ID+"\",\n \"sub\": \""+ sub +"\",\n \"per\": {\n \"voice\": {\n \"incoming_allow\": true,\n \"outgoing_allow\": true\n }\n }}");
Request request = new Request.Builder()
.url("https://api.plivo.com/v1/Account/MAY2RJNZKZNJMWOTG4NT/JWT/Token")
.url("https://api.plivo.com/v1/Account/"+Utils.AUTH_ID+"/JWT/Token")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Basic TUFZMlJKTlpLWk5KTVdPVEc0TlQ6WWpJM1pXVmpPV0poTW1Kak5USXhNakJtTkdJeVlUUmtZVGd3TUdSaA==")
.addHeader("Authorization", "Basic "+Utils.AUTH_TOKEN)
.build();
try {
/*runOnUiThread(() -> {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/plivo/plivosimplequickstart/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class Utils {
// endpoint username & password
static final String USERNAME = BuildConfig.Username;
static final String PASSWORD = BuildConfig.Password;
static final String AUTH_ID = BuildConfig.AuthID;
static final String AUTH_TOKEN = BuildConfig.AuthToken;

static final String PREFERENCE_KEY = "Plivo-Pref";

Expand Down