logo
down
shadow

Android Google Sign in Exceptions


Android Google Sign in Exceptions

By : user2187192
Date : November 26 2020, 04:01 AM
Hope that helps I want to get the exceptions caused when a user fails to log into my app using Google Sign in. For example, in the handleSignInResult(@NonNull Task completedTask) method I use this: , This is what I should use:
code :
private void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTask) {
    try {
        account = completedTask.getResult(ApiException.class);
        if(isSignedIn()) {
            Toasty.success(this, "Success!", Toast.LENGTH_SHORT, true).show();
            startActivity(new Intent(MainActivity.this, Home.class));
        }
    } catch (ApiException e) {
        if(e.getCause() != null) {
            Toast.makeText(this, "Failed to login because: " + e.getCause(), Toast.LENGTH_LONG).show();
        }
        else {
            Toast.makeText(this, "Failed to login because: No account Selected!", Toast.LENGTH_LONG).show();
        }
    }
}`


Share : facebook icon twitter icon
Android - Google Sign-in on Web API - How to send Google Sign-in POST-request?

Android - Google Sign-in on Web API - How to send Google Sign-in POST-request?


By : Felix Davis
Date : March 29 2020, 07:55 AM
help you fix your problem Ok, I've found the POST I can use in the C# web project (/POST/ExternalLogin). There I also see what I should send:
In the header:
code :
public class TaskPostAPI extends AsyncTask<String, Void, String>
{
    private String TOKEN = "__RequestVerificationToken";

    @Override
    protected String doInBackground(String... urls){
        String response = "";
        for(String url : urls){
            HttpPost post = new HttpPost(url);
            try{
                // Add the default Content-type to the Header
                post.addHeader("Content-type", "application/x-www-form-urlencoded");

                // Get the baseUrl from the given url
                URL u = new URL(url);
                String baseUrl = u.getProtocol() + "://" + u.getHost();

                // POST-request requires anti-forgery Cookie
                // Get all Cookies
                CookieManager cookieManager = CookieManager.getInstance();
                String cookie = cookieManager.getCookie(baseUrl);
                String[] cookies = cookie.split(";");

                // Put all Cookies in a HashMap with cookieKey & cookieToken
                HashMap<String, String> cookieStrings = new HashMap<String, String>();
                for(String cook : cookies){
                    String[] cs = cook.split("=");
                    cookieStrings.put(cs[0], cs[1]);
                }

                // Add the Cookie to the Header
                post.addHeader("Cookie", TOKEN + "=" + cookieStrings.get(TOKEN) + "");

                // POST-request requires cookieToken, provider and returnUrl
                List<NameValuePair> nvPairs = new ArrayList<NameValuePair>(3);
                nvPairs.add(new BasicNameValuePair(TOKEN, cookieStrings.get(TOKEN)));
                nvPairs.add(new BasicNameValuePair("provider", "Google"));
                nvPairs.add(new BasicNameValuePair("returnUrl", baseUrl));
                post.setEntity(new UrlEncodedFormEntity(nvPairs));

                Log.i("COOKIE OUTPUT", TOKEN + "=" + cookieStrings.get(TOKEN) + "");

                // Send the POST-request
                HttpResponse execute = MainActivity.HttpClient.execute(post);

                // Get the response of the POST-request
                InputStream content = execute.getEntity().getContent();
                BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
                String s = "";
                while((s = buffer.readLine()) != null)
                    response += s;
            }
            catch(Exception ex){
                ex.printStackTrace();
            }
        }
        return response;
    }
Android app Facebook Sign-In remembers user, but Google Sign In doesn't

Android app Facebook Sign-In remembers user, but Google Sign In doesn't


By : Bebu
Date : March 29 2020, 07:55 AM
I hope this helps you . So I've implemented Facebook sign-in, now I've implemented Google. It signs in successfully, but when I restart the app, the user has to log in again. If I log in with FB however, it does as it should. Here's my AuthListener: , I solved it myself. I was missing the firebaseAuthWithGoogle method:
code :
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d("AD", "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d("AD", "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w("AD", "signInWithCredential", task.getException());
                        Toast.makeText(SignUp.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                    // ...
                }
            });
}
if (result.isSuccess()) {
            // Signed in successfully, show authenticated UI.
            GoogleSignInAccount account = result.getSignInAccount();
                firebaseAuthWithGoogle(account);
        } 
How to differentiate between first time google Sign-In and successive google sign-In in an android application?

How to differentiate between first time google Sign-In and successive google sign-In in an android application?


By : akindone
Date : March 29 2020, 07:55 AM
Hope that helps Why don't you save the google sign-in token in your local database and every time the user opens the application make a check for the user token (maybe in your splash) and if it is present it means there is already an existing user make an intent to the profile activity. Else personal-details activity.
After once login with google authentication in my android app i can't sign out. every time it's automatically sign in

After once login with google authentication in my android app i can't sign out. every time it's automatically sign in


By : Christopher Vega
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You also need to sign out from GoogleSignInClient and FirebaseAuth current user, something like this:
code :
 //sign out of the user and start login activity.
public void signOut() {
    signOutBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail()
                    .build();
           GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(getContext(), gso);
           mGoogleSignInClient.signOut();
           FirebaseAuth.getInstance().signOut();
           startActivity(new Intent(getContext(), LoginActivity.class));
        }
    });
}
integration Facebook sign-in , Google+ sign-in in Android app

integration Facebook sign-in , Google+ sign-in in Android app


By : Pawel C
Date : March 29 2020, 07:55 AM
hop of those help? I tried knowledge base before asking this question but I didn't find anything relevant. , Inside and put this node:
Related Posts Related Posts :
  • How do I make this image larger?
  • Run icCube with JDK 10
  • Expression with Math.random() always returns the same value
  • Getting the Set with the most elements nested in a HashMap using Java Streams
  • XmlSlurper to parse XML and get value of inside elements using Groovy
  • Extracting data from HTML and formatting the output
  • SOLR documentCache JMX metrics clarification
  • Limiting Wildfly 14 Two-Way SSL to specific clients
  • How do I get Min and max values to only print when "year" is entered?
  • Hashmap can't loop - getKey() method not found - Using Java 8
  • Android Studio - Create an EditText with a click of a button
  • Mockito Test not invoking verify() method
  • Wrap method implementations of Java interfaces
  • Remediating dynamic SQL into prepared statements
  • Where do X and Y start at in swing windows
  • java code with files work from eclipse but dont work from cmd
  • Return page object from JPA query
  • I can't figure out why this code in my APCS multiple choice book returns 19
  • How to save data between methods
  • I'm trying to install Apache Gobblin. How can I install it using Gradle?
  • Spring Data Sorting Array or Set into Pageable
  • Question about the Java documentation and its implementation
  • How to make a JButton that when pressed it does a new action
  • Java hibernate No validator could be found for boolean
  • Making a POJO Thread Safe
  • Save the data of a text file in a arraylist
  • Sort a List<String[]> by indices using Comparator
  • Overloading in Java for user input?
  • Unable to format timestamp as YYYY-MM-DD HH:mm:ss in java
  • Access SQLite Helper From Adapter
  • How to stream a csv file with header to a HashMap<String, Double> in Java?
  • can't get go daddy ssl certificate to work with spring boot
  • ResourceBundle can't find BaseName gradle project java
  • Java; Jackson; Parsing the array of array json string
  • Java - map key lookup ignoring case
  • Jackson deserialize map null values to empty string
  • Anyone knows why setCount() is not working in twitter4j?
  • Object Visibility in a Multi-threaded Program in Java
  • Can't store and load an arraylist in an object file
  • convert a string number starts with `00` to `+` in java
  • Java - avoiding NonSuchElementException using ConcurrentLinkedDeque
  • Converting Immutable to mutable list Java
  • Getting nosuchmethod exception
  • How to get MQTT subscriptions
  • JavaFX - method that waits for user input
  • Replacing values for a particular key in treemap changes values for every key
  • This method call passes a null value for a nonnull method parameter. Either the parameter is annotated as a parameter th
  • Kafka: consume all messages on demand
  • Notify what text was changed in textview
  • Tinkerpop/Gremlin: select vertices together with outgoing edge count
  • transform a list of objects into a list of integers that pass a check
  • Why this java code is showing strange behavior?
  • Maven Project classes not compiling
  • Edit image to make text more clear opencv
  • Android Spinner nullpointer
  • Add result to int array every time you finish counting the occurrence
  • Android import java library
  • How to use LDAP Authentication in a corporate environment
  • adding item during iteration in java special usecase
  • How can I sort a map with string key? like (1 foo , 2 foo)
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org