How to solve “301 moved permanently” in android webview?

806 views
Skip to first unread message

adnan raja

unread,
Nov 2, 2010, 1:38:20 AM11/2/10
to foursquare API
I am trying to implement foursquare OAuth based authentication in my
android app. It works fine in my Andorid web browser, but it displays
"301 moved permanently" error in Android webview. I tried to debug it
and found that it displays the error on following URL:


https://foursquare.com/mobile/login?continue=%2Fmobile%2Foauth%2Fauthorize%3Foauth_token={my_token}


But the same URL works fine on Andriod browser. So, I think there is
something need to be done with webview settings.

Anyone can help?

Dave Ingram

unread,
Nov 2, 2010, 8:52:09 AM11/2/10
to foursqu...@googlegroups.com, adnan raja
I can't remember the details offhand (I'll have to check my code later),
but the WebView needs a few methods hooked up to it in order to allow
you to visit URLs. This apparently includes redirects too.

Hopefully this should put you on the right path -- if not, I'll dig out
my code later.


D

adnan raja

unread,
Nov 8, 2010, 2:22:19 AM11/8/10
to foursquare API
I have solved this issue by overriding following method:

@Override
public void onReceivedSslError(WebView view, SslErrorHandler
handler,
SslError error) {

handler.proceed();
}



On Nov 2, 5:52 pm, Dave Ingram <d...@dmi.me.uk> wrote:
>  On 02/11/10 05:38, adnan raja wrote:> I am trying to implement foursquare OAuth based authentication in my
> > android app. It works fine in my Andorid web browser, but it displays
> > "301moved permanently" error in Android webview. I tried to debug it
> > and found that it displays the error on following URL:
>
> >https://foursquare.com/mobile/login?continue=%2Fmobile%2Foauth%2Fauth...{my_token}

marionegroponzi

unread,
Dec 20, 2010, 6:41:19 AM12/20/10
to foursquare API
The API is a Level 8 API, so not available on most devices.

Also, we should not ignore SSL error messages, as it open doors to
attacks.

Foursquare should fix the certificate.

Cheers,
Mario

marionegroponzi

unread,
Dec 20, 2010, 6:36:25 AM12/20/10
to foursquare API
The API is available only Since: API Level 8, so no luck with the vast
majority of devices.

Moreover, ignoring the ssl error doesn't look like a correct approach
as we would be ignoring also valid errors and potential attacks.

I think Foursquare should fix the certificate.

Cheers,
Mario

On Nov 8, 8:22 am, adnan raja <adnanmemo...@gmail.com> wrote:
> I have solved this issue by overriding following method:
>
>  @Override
>         public void onReceivedSslError(WebView view, SslErrorHandler
> handler,
>                 SslError error) {
>
>             handler.proceed();
>         }
>
> On Nov 2, 5:52 pm, Dave Ingram <d...@dmi.me.uk> wrote:
>
>
>
>
>
>
>
> >  On 02/11/10 05:38, adnan raja wrote:> I am trying to implement foursquare OAuth based authentication in my
> > >androidapp. It works fine in my Andorid web browser, but it displays
> > > "301moved permanently" error inAndroidwebview. I tried to debug it
Reply all
Reply to author
Forward
0 new messages