Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1069747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:28:02+00:00 2026-05-16T20:28:02+00:00

I’m building a Webapp that uses OpenId to authenticate users, like Stackoverlfow does. There

  • 0

I’m building a Webapp that uses OpenId to authenticate users, like Stackoverlfow does. There will be a mobile App too, e.g. Android or iPhone. These Apps have to authenticate or login somehow, to access data and update stuff that belongs to the user. Since there is no username and password one could provide to authenticate the mobile device, I wonder how to achieve this.

Two ways came into my mind:

  1. Generate some key on the server that must be entered on the device. This key will be send as auth-key when the mobile device sends or requests data and the user can be linked that way. When using this Option, the key should be transported somehow to the user, so he doesn’t have to type it in. Maybe via email, SMS or by scanning a barcode.

  2. The mobile App uses the Browser or shows an integrated Web-Panel that opens a special page of the Webapp. On this page, the user has to login in, and could then allow the mobile App to read and write data.

My question is: Are both ways possible and safe? Which one would you prefer? What are the details to watch out for? Are there any other ways to do this? If I got it all right, it would not be possible to use OpenId on the Device, and link the mobile and the webapp that way, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:28:02+00:00Added an answer on May 16, 2026 at 8:28 pm

    I have done the following to achieve this:

    • When the App first starts, I test if
      there is an authentication token and
      if it is still valid
    • If not, I use [startActivityForResult][1] to open my login activity
    • The LoginActivity uses a WebView and opens the “authenticate app” page (e.g. https://www.yourdomain.com/authapp) from the web application.
    • If the user is not logged into the webapp, he has to do this now. Upon successful login, he gets redirected to the “authenticate app” page
    • The “authenticate app” page contains the text “would you like the mobile app to access you data” and a “grant” and “cancel” button.
    • If the user hits “grant” the web app generats a authentication token, writes it to the databse and redirects to a response page, attaching the generated authentication token to the URL (e.g. https://www.yourdomain.com/authresponse?auth_token=dshf84z4388f4h)
    • The mobile application extracts the token from the URL and uses it for authentication when talking to the server.

      The WebLogin Activity looks like this: (note: you have to override “shouldOverrideUrlLoading” to stay in the same WebView. Otherwise, a new browser is open when you receive some redirect)

      public class WebLogin extends Activity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      WebView webview = new WebView(this);
      webview.setWebViewClient(new WebViewClient() {  
      
          @Override  
          public boolean shouldOverrideUrlLoading(WebView view, String url){
              view.loadUrl(url);
              return true;  
          }  
      
          @Override
          public void onPageFinished(WebView view, String url) {
      
              if(StringUtils.contains(url, "?auth_token=")){
      
                  // extract and save token here
      
                  setResult(RESULT_OK);
                  finish();
              }
          }
      });
      
      webview.loadUrl("https://www.yourdomain.com/authapp");
      webview.getSettings().setJavaScriptEnabled(true);
      setContentView(webview);
      

      }
      }

    Note, I use https to make this save. If you use plain http, one could read and steal the token of a user.

    [1]: http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.