microsoft/Cognitive-Face-Android

Support endpoint settings alongside with subscription key in Sample.

Closed this issue · 13 comments

Support endpoint settings alongside with subscription key in Sample.

@huxuan
I am trying to use the sample Cognitive-Face-Android from github. the dependency to the project oxford in the maven repository is there but the problem is that the compile classes.jar contains the host name for westus and the trial subscription that I got is for westcentralus and I could not change the hostname in the classes.jar. As such I get the "Access denied. Invalid subsription key" error. Can you pls advise how I can change the hostname so that I bypass the error? if I cannot change the hostname since it is being brought in from the project oxford library, can you tell me which country I should choose when getting the subscription key so that I get that ones that will work for WESTUS region. When I tried to get the Trial key, I used the country to be US but did not work for WESTUS but works for WESTCENTRALUS. I did not use the Azure portal to get the key as i dont want to enter my credit card information yet since i only want to do the 30 day trial and see how good the API case works and see if I will have a use case for deploying it. So if anyone can advise me:
1- how to change the hostname to WESTCENTRALUS or
2- tell me which country I should use when getting the TRIAL license that will work with WESTUS if I cannot change the Hostname in the Android sample project.
Thanks

1- how to change the hostname to WESTCENTRALUS

For SDK, the initialization of FaceServiceRestClient support to set the region (serviceHost) here [1].

2- tell me which country I should use when getting the TRIAL license that will work with WESTUS if I cannot change the Hostname in the Android sample project.

You should use westcentralus for the free trial keys.

Sorry for the inconvenience brought by the changes of Azure Website. The website is maintained by a different team and they changed the region for free trial keys during the BUILD conference, which should be westus previously, that is why we use westus as default value.

[1] https://github.com/Microsoft/Cognitive-Face-Android/blob/1.3.0/ClientLibrary/lib/src/main/java/com/microsoft/projectoxford/face/FaceServiceRestClient.java#L92

@huxuan
Thank you for you response. As for changing that hotsname to WESTCENTRALUS, I did try that in the FaceServiceRestClient.java file but despite that, when I do the Build>Make Project or Rebuild Project, the classes.jar file from the external library still shows WESTUS so when I try to run the "app" I still get the "Invalid Subscription key". Please see attached screenshot. Kindly advise what i should do. My apologies if I did not understand what I should do. I am a newbie and would want to explore the sample. Thank you for your patience.
I also change the serviceHost in the java file to this
public FaceServiceRestClient(String "https://westcentralus.api.cognitive.microsoft.com/face/v1.0", String subscriptionKey) - Did i do it right? I still get the "Invalid subscription key"
face api

@Phumba2 Changing the source code of SDK will not help cause you are still using the lib downloaded from maven. You should invoke the initialization directly with something like

FaceServiceClient faceServiceClient = new FaceServiceRestClient("https://westcentralus.api.cognitive.microsoft.com/face/v1.0", "<your subscription key here>");

@huxuan
Thanks. Where do I put that? Is it still in the ..\ClientLibrary\lib\src\main\java\com\microsoft\projectoxford\face\FaceServiceRestClient.java file and do I replace the line that has "public" (see screen shot) with the exact line of code you provided above? Again, my apologies since I am really new even to this android thing.
faceapi2

@Phumba2 I mean you need to change it in your code or the sample here [1]. Changes in the SDK will not take effect as I have mentioned.

[1] https://github.com/Microsoft/Cognitive-Face-Android/blob/1.3.0/Sample/app/src/main/java/com/microsoft/projectoxford/face/samples/helper/SampleApp.java

@huxuan
Thank you. Can you confirm that this is what I should put in the sampleapp.java replacing the original line
original line commented out//sFaceServiceClient = new FaceServiceRestClient(getString(R.string.subscription_key));
FaceServiceClient faceServiceClient = new// FaceServiceRestClient("https://westcentralus.api.cognitive.microsoft.com/face/v1.0", "**************");

@Phumba2 Yes, you are right, but you should not expose your subscription key here. (edited that for you)

@huxuan - Thank you very much for the confirmation and for masking my key. I confirm that the "Invalid Subscription key" error is gone. However, I still get an error. Using an android emulator, I try to do a "Detection" or "Add a group" in the Identification but both gets an error. The picture is in jpeg format and size is 54KB which complies with the limits specified in the FACE API documentation. Kindly see the attached screen shots for the actual error. Would you be kind enough to let me know what I need to do to fix the error? Thank you in advance.
face api3

@Phumba2 please do not be off topic. We have official support on stackoverflow with tag 'microsoft-cognitive'. Just make your question prepared and ask there.

Thanks @huxuan. I have posted the new question here.

@Phumba2 This is github issue page, not support forum please do not spam here. (Might delete all these unrelated posts one week later)

Fixed by #17