0

I am developing an Android Application with access to an external API. To access the API, it is necessary to implement OAuth2 protocol. I have set up everything, my API call to get an authorization code is working, but does not return anything.

Reason is at my Callback_url. I have set up a connection in my Manifest, the Activity and the API EndPoint settings. The callback_url is set up in the following format "https://xxxxxxxxx.com".

However, the callback URL specified is not in production, so it does not return the verifier to the application. Is there a temporary solution to get the verifier code when developing an application locally?

Niels Vanwingh
  • 444
  • 4
  • 18
  • you should put some example code in order to let people helps you – Alessandro.Vegna Mar 08 '18 at 09:22
  • Hello Alessandro, question is about a way of working, not about the code.. Is there a temporary solution for callback_url to get the verifier code in OAuth2 when developing an application locally? – Niels Vanwingh Mar 08 '18 at 09:25
  • I don't know if this is what you are looking for or not, but let me suggest it anyway. You can keep two different `Manifest.xml` for debug and production. So you can keep production connections in production manifest and development connections in debug manifest. – Dhrumil Patel Mar 08 '18 at 09:28
  • Not exactly, but it can still help, thank you for replying.. – Niels Vanwingh Mar 08 '18 at 09:30
  • any luck with my answer? @NielsVanwingh – Alessandro.Vegna Mar 08 '18 at 13:53
  • I received the advice to add a Web BackEnd to my application to perform the API calls. Still remains the question if I can use http://locallhost.com/ for Development Purposes and how to set up the FireBase OAuth2 Process.. – Niels Vanwingh Mar 09 '18 at 09:09

2 Answers2

1

From Patel's answer I can suggest you to have a look at build variants:

https://developer.android.com/studio/build/build-variants.html

and put into your code something like:

if (BuildConfig.FLAVOR.equals("production")) {
    //do something for production
}else {
    //do something for test
}
Alessandro.Vegna
  • 1,242
  • 10
  • 19
  • 1
    Thank you for the comment, I will certainly need to look into this.. For now, I just want to set up a Development callback_url to start working with the API.. – Niels Vanwingh Mar 09 '18 at 09:25
0

I have set a callback_uri for Development Purposes, "http://locallhost.com/". This is working in a web browser but not on Emulator. So there should be an issue with my configuration..

The Request sent is correct, so the parameters in my MainActivity are correct. In the Application Setting on the FitBit Developers page, I have set all parameters correctly.

Last thing I have done is included an Internet Permission and an Intent Filter in my Android Manifest File..

Intent Filter is the following:

<intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:host="http://locallhost.com/"
                    android:scheme="oauth"/>
            </intent-filter>

Is my Intent Filter correct?

Am I forgetting something?

  • Internet Permission

  • Application Settings EndPoint

  • Configure the Activity

  • Configure Intent Filter in the Manifest

Niels Vanwingh
  • 444
  • 4
  • 18