2

Firstly, I read the documentation. I enabled GitHub auth from the console and typed OAuth app info, such as client_id, etc. But I got confused about how should I do it. In the documentation, there are some Java codes like that. But I want to do that in Kotlin and also not just "copy-pasting" it:

Task<AuthResult> pendingResultTask = firebaseAuth.getPendingAuthResult();
if (pendingResultTask != null) {
  // There's something already here! Finish the sign-in for your user.
  pendingResultTask
      .addOnSuccessListener(
          new OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
              // User is signed in.
              // IdP data available in
              // authResult.getAdditionalUserInfo().getProfile().
              // The OAuth access token can also be retrieved:
              // ((OAuthCredential)authResult.getCredential()).getAccessToken().
            }
          })
      .addOnFailureListener(
          new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
              // Handle failure.
            }
          });
} else {
  // There's no pending result so you need to start the sign-in flow.
  // See below.
}

// The user is already signed-in.
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();

firebaseUser
    .startActivityForLinkWithProvider(/* activity= */ this, provider.build())
    .addOnSuccessListener(
        new OnSuccessListener<AuthResult>() {
          @Override
          public void onSuccess(AuthResult authResult) {
            // GitHub credential is linked to the current user.
            // IdP data available in
            // authResult.getAdditionalUserInfo().getProfile().
            // The OAuth access token can also be retrieved:
            // authResult.getCredential().getAccessToken().
          }
        })
    .addOnFailureListener(
        new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception e) {
            // Handle failure.
          }
        });

Simply what I want to do is get this:

enter image description here

After the user clicked GitHub icon and then redirects it to the GitHub page. What should I do?

0 Answers0