Change eBay search from US to UK - android

I am trying to change the search site that my eBay Android app searches in. At the moment, it searches the US site, but I would like it to search the UK site.
Here's my findingServiceClient class that I'm trying to make search the UK site, with the country code 3(UK, source).
As far as I can see I have set my code up to search the UK site, but it still seems to search the US.
any help would be appreciated, thanks.
public class FindingServiceClient {
// production
public static String eBayFindingServiceURLString = "http://svcs.ebay.com/services/search/FindingService/v1";
// sandbox
//public static String eBayFindingServiceURLString = "https://svcs.sandbox.ebay.com/services/search/FindingService/v1";
public static String eBayAppId = "ebay_app_id";
private static volatile FindingServicePortType_SOAPClient client = null;
public static String targetSiteid = "3";
public static FindingServicePortType_SOAPClient getSharedClient() {
if (client == null) {
synchronized(FindingServiceClient.class) {
if (client == null) {
client = new FindingServicePortType_SOAPClient();
client.setEndpointUrl(eBayFindingServiceURLString);
client.setSoapVersion(SOAPVersion.SOAP12); // ebay finding service supports SOAP 1.2
client.setContentType("application/soap+xml");
client.getAsyncHttpClient().addHeader("X-EBAY-API-SITE-ID", targetSiteid);
client.getAsyncHttpClient().addHeader("Accept", "application/soap+xml");
client.getAsyncHttpClient().addHeader("X-EBAY-SOA-SECURITY-APPNAME", eBayAppId);
client.getAsyncHttpClient().addHeader("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP12");
client.getAsyncHttpClient().addHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT", "SOAP");
}
}
}
return client;
}
}

The site that is searched is specified in the HTTP header X-EBAY-SOA-GLOBAL-ID. The value of this header is not a unique integer, such as 3, but a unique string, such as EBAY-US. To search the UK site you need to make the two below changes to your code and remove any reference to X-EBAY-API-SITE-ID.
public static String targetSiteid = "EBAY-GB";
client.getAsyncHttpClient().addHeader("X-EBAY-SOA-GLOBAL-ID", targetSiteid);
The eBay docs provide a complete list of HTTP headers and a table of site IDs mapped to global IDs.

Related

Go-Ethereum: Android Smart Contract Interaction Issue

I am attempting to interact with a smart contract via mobile (android) using the go-ethereum library.
Android
final String address_string = "0x8607e627604495ae9812c22bb1c98bdcba581978";
String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"get_s\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"new_s\",\"type\":\"string\"}],\"name\":\"set_s\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"d_s\",\"type\":\"string\"}],\"payable\":false,\"type\":\"constructor\"}]";
Address address = Geth.newAddressFromHex(address_string);
BoundContract contract = Geth.bindContract(address, abi, ec);
CallOpts callOpts = Geth.newCallOpts();
callOpts.setContext(ctx);
callOpts.setGasLimit(31500);
System.out.println("OUTPUT: " + getString(contract, callOpts));
//Setter String to Test Contract
Interfaces params = Geth.newInterfaces(1);
Interface anInterface = Geth.newInterface();
anInterface.setString(teststring);
params.set(0,anInterface);
return contract.transact(opts, "set_s", params);
//Getter String from Test Contract
Interfaces args = Geth.newInterfaces(0);
Interfaces results = Geth.newInterfaces(1);
Interface result = Geth.newInterface();
result.setDefaultString();
results.set(0, result);
contract.call(opts, results, "get_s", args);
String string = results.get(0).getString();
return string;
Contract
pragma solidity ^0.4.9;
contract echo {
string s;
function echo(string d_s) {
s = d_s;
}
function set_s(string new_s) {
s = new_s;
}
function get_s() returns (string) {
return s;
}
}
Expected behaviour
Successful interaction with a deployed smart contract on the Rinkeby blockchain.
Actual behaviour
For setter (on contract):
'abi: cannot use slice as type string as argument'
For getter (on contract):
'abi: cannot unmarshal string in to []interface {}'
Steps to reproduce the behaviour
1.) Connect to Rinkeby Testnet via mobile
2.) Create an account via mobile
3.) Deploy a smart contract via desktop
4.) Try to interact w/ the smart contract via mobile
Bottom Line
If anyone has been able to interact with smart contracts through go-ethereum android,
I would appreciate some assistance.
fix for that issue.
https://github.com/ethereum/go-ethereum/pull/15402
I'm waiting for feedback.

MobileHub where to store API keys

I am building an app based on the mobile hub sample app. The sample-app has the API keys stored in a class file AWSconfiguration:
public class AWSConfiguration {
// AWS MobileHub user agent string
public static final String AWS_MOBILEHUB_USER_AGENT =
"MobileHub ********* aws-my-sample-app-android-v0.16";
// AMAZON COGNITO
public static final Regions AMAZON_COGNITO_REGION =
Regions.fromName("us-east-1");
public static String AMAZON_COGNITO_IDENTITY_POOL_ID = "us-east-************6";
// Google Client ID for Web application
public static String GOOGLE_CLIENT_ID ="";//"*********************.apps.googleusercontent.com";
public static final Regions AMAZON_DYNAMODB_REGION =
Regions.fromName("us-east-1");
public static String AMAZON_COGNITO_USER_POOL_ID = "************";
public static String AMAZON_COGNITO_USER_POOL_CLIENT_ID = "*************";
public static String AMAZON_COGNITO_USER_POOL_CLIENT_SECRET = "*************";
private static final AWSMobileHelperConfiguration helperConfiguration = new AWSMobileHelperConfiguration.Builder()
.withCognitoRegion(AMAZON_COGNITO_REGION)
.withCognitoIdentityPoolId(AMAZON_COGNITO_IDENTITY_POOL_ID)
.withCognitoUserPool(AMAZON_COGNITO_USER_POOL_ID,
AMAZON_COGNITO_USER_POOL_CLIENT_ID, AMAZON_COGNITO_USER_POOL_CLIENT_SECRET)
.build();
/**
* #return the configuration for AWSKit.
*/
public static AWSMobileHelperConfiguration getAWSMobileHelperConfiguration() {
return helperConfiguration;
}
}
It seems unsafe to store the client secret key this way. What are the risks?
I experiemnted with hiding the keys in JNI files but could not find the proper entry point in the activity to set the keys before they are called from the mobile helper.
Storing in clear text is generally a bad idea, as you guessed. You could use the android keystore, store it encrypted (the stronger the key, the better), obfuscate it with some unique identifier of your device, or access it via some API you control and secure. It's possible to use some other solution, or a combination of the above possibilities. The final decision comes down to you and what your app needs/abilities are, but there's a few ways to hide it.
SharedPreferences.Editor can be a solution.
Password or something like this are stored in SharedPreferences.

Limit access to my endpoints to my Android app only

I'm new to the Google App Engine, and I'm trying to make my first engine and connect it to my Android app. I have walked through this tutorial in order to learn about it:
https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/helloendpoints-android-studio
I got it to work fine. I can access my app engine from my android app, and get the wanted response. The problem is, I want to restrict the endpoints of my API to my app's users only.
This is my API method (from the tutorial), and as for now, everyone can access my api's explorer and execute methods in it, as long as they are logged in to any Google account.
I want the users to be able to execute this method from my app only.
This is my app engine java file:
package com.example.Barda.myapplication.backend;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.response.UnauthorizedException;
import com.google.appengine.api.users.User;
import javax.inject.Named;
/**
* An endpoint class we are exposing
*/
#Api(
name = "myApi",
version = "v1",
clientIds = {Constants.ANDROID_CLIENT_ID},
audiences="firebase-wiki-race.appspot.com",
namespace = #ApiNamespace(
ownerDomain = "backend.myapplication.Barda.example.com",
ownerName = "backend.myapplication.Barda.example.com",
packagePath = ""
)
)
public class MyEndpoint {
/**
* A simple endpoint method that takes a name and says Hi back
*/
#ApiMethod(name = "sayHi")
public MyBean sayHi(#Named("name") String name) throws UnauthorizedException {
// if (user == null) throw new UnauthorizedException("User is Not Valid");
MyBean response = new MyBean();
response.setData("Hi, " + name);
return response;
}
}
This is constants class:
package com.example.Barda.myapplication.backend;
/**
* Contains the client IDs and scopes for allowed clients consuming your API.
*/
public class Constants {
public static final String ANDROID_CLIENT_ID = "*********************.apps.googleusercontent.com";
}
I have generated using my app's SH-1 and package name the ANDROID_CLIENT_ID.
I have searched online a lot, and read blogs and threads, but I couldn't make it work. Is this a possible thing to do? What am I doing wrong?
You'll want to follow the documentation's guide on adding authorization to the API backend. In this process you define a list of clients that are authorized to use your Endpoint.
Once that's done you can follow the guide on making authenticated calls from Android.

unable to send a notification to myself

After I followed all the steps for the push notification sample app. I wasn't able to send a notifaction to myself. I could send a pushmessage from my PC to my phone, but when I use the button Send myself a Notification nothing happens.
I am using Android sdk
After starting the app I do see that my Device is Registerd
Here is my settings.java
package com.ganyo.pushtest;
/** Change these values to match your setup! */
public class Settings {
static final String UNASSIGNED_ORG_VALUE = "";
// Google Client Id from Google API Console
static final String GCM_SENDER_ID = "xxxxxxxxxxxxx";
// Notifier Name in App Services
static final String NOTIFIER = "androidDev";
static final String API_URL = "https://api.usergrid.com";
static final String ORG = "xxxxxxx";
static final String APP = "sandbox";
// set these if you want to use a user login
static final String USER = null;
static final String PASSWORD = null;
}
I'm not sure what the UNASSIGNED_ORG_VALUE should be.
Thx in advance.
No need to assign any value to UNASSIGNED_ORG_VALUE. It's only used to check that you've entered the other values.
Please check your Android logs as well as the Apigee Console to see what error messages might have been generated during your push attempt. This will help you debug the issue.
Finally, you could try providing your notifier name here in all lowercase. (Note: This shouldn't generally be necessary, but I've heard there may be a issue that affects notifier name resolution.)

What are the response codes (values) returned by the Google Play server in a license response?

I want to cater for LICENSE_OLD_KEY in my android license policy.
I was going to modify the ServerManagedPolicy as it doesn't cater for this, as far as I can tell, it just seems to look for Policy.LICENSED or Policy.NOT_LICENSED in processServerResponse method:
public void processServerResponse(int response, ResponseData rawData) {
// Update retry counter
if (response != Policy.RETRY) {
setRetryCount(0);
} else {
setRetryCount(mRetryCount + 1);
}
if (response == Policy.LICENSED) {
// Update server policy data
Map<String, String> extras = decodeExtras(rawData.extra);
mLastResponse = response;
setValidityTimestamp(extras.get("VT"));
setRetryUntil(extras.get("GT"));
setMaxRetries(extras.get("GR"));
} else if (response == Policy.NOT_LICENSED) {
// Clear out stale policy data
setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);
setRetryUntil(DEFAULT_RETRY_UNTIL);
setMaxRetries(DEFAULT_MAX_RETRIES);
}
setLastResponse(response);
mPreferences.commit();
}
I'd like to know what the response code is for LICENSE_OLD_KEY because that doesn't exist in Policy:
public static final int LICENSED = 0x0100;
public static final int NOT_LICENSED = 0x0231;
public static final int RETRY = 0x0123;
I had a look here, but I can't find anywhere that lists the name and values.
I can see that there are a list of server response codes in LicenseValidator but they don't match up to those in Policy:
// Server response codes.
private static final int LICENSED = 0x0;
private static final int NOT_LICENSED = 0x1;
private static final int LICENSED_OLD_KEY = 0x2;
private static final int ERROR_NOT_MARKET_MANAGED = 0x3;
private static final int ERROR_SERVER_FAILURE = 0x4;
private static final int ERROR_OVER_QUOTA = 0x5;
private static final int ERROR_CONTACTING_SERVER = 0x101;
private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;
private static final int ERROR_NON_MATCHING_UID = 0x103;
Giving it some thought I decided to try displaying the reason codes returned by the Google Play server on my phone, using AlertDialog's. Here is what I found:
Selecting LICENSED, in the Developer console profile, returned the number 256, as per Policy.LICENSED.
Selecting NOT_LICENSED returned the number 561, again as per Policy.NOT_LICENSED.
Finally selecting LICENSED_OLD_KEY returned the number 256, which is the same as Policy.LICENSED.
So it would seem that LICENSED_OLD_KEY is no longer used, or rather there is no distinction between LICENSED and LICENSED_OLD_KEY. Which is a bit confusing given the information that google provide in their documentation here.
Just to note, I did try uninstalling my app and selecting the different options in the developer console a few times, but it always resulted in the same answer!
The code you're looking at is only a reference implementation. It can't know how you would want to deal with a LICENSED_OLD_KEY situation in detail. The documentation suggests you might want to limit access to the current app, or to your server data from the current app, and ask the user to update and use the latest version. There's nothing much a reference implementation can provide to enable you to deal with all these situations. You can and should modify the code to treat LICENSED_OLD_KEY separately.
There's no indication for LICENSED_OLD_KEY "not being used anymore" because it's still handled as a server response in LicenseValidator.java and "OLD_KEY" refers to an older version of your app, not an older version of Google Play server handling.

Categories

Resources