當前位置: 首頁>>代碼示例>>Java>>正文


Java Auth類代碼示例

本文整理匯總了Java中com.google.android.gms.auth.api.Auth的典型用法代碼示例。如果您正苦於以下問題:Java Auth類的具體用法?Java Auth怎麽用?Java Auth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Auth類屬於com.google.android.gms.auth.api包,在下文中一共展示了Auth類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LoginGoogle

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
public LoginGoogle(final Context context, SignInButton button, final Activity act, PreferencesShared pref) {
    this.context = context;
    preferencesShared = pref;
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)).requestScopes(new Scope(Scopes.PLUS_ME)).requestEmail().requestIdToken("473547758853-nm840bumsu5km04gbgtdee1fhtod1ji6.apps.googleusercontent.com").build();
    mGoogleApiClient = new GoogleApiClient.Builder(context.getApplicationContext())
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    button.setSize(SignInButton.SIZE_STANDARD);
    button.setScopes(gso.getScopeArray());

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            act.startActivityForResult(signInIntent, 101);

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:24,代碼來源:LoginGoogle.java

示例2: initGoogleApiClient

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
private void initGoogleApiClient() {
    final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .requestScopes(new Scope(SCOPE_PICASA))
            .build();
    googleApiClient = new GoogleApiClient.Builder(activity)
            .enableAutoManage(activity,
                    connectionResult -> emitter.onError(new SignInException("Connecting", connectionResult.getErrorMessage(), connectionResult.getErrorCode())))
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    actWhenConnected();
                }

                @Override
                public void onConnectionSuspended(int i) {

                }
            })
            .build();
}
 
開發者ID:yosriz,項目名稱:RxGooglePhotos,代碼行數:24,代碼來源:GoogleSignOutOnSubscribe.java

示例3: onClick

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.sign_in_button:
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, 1);
            break;
        case R.id.sign_out_button:
            Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                    new ResultCallback<Status>() {
                        @Override
                        public void onResult(Status status) {
                            Log.w("credentials","Status: "+ status.getStatus());
                            Log.w("credentials","StatusMessage: "+ status.getStatusMessage());
                        }
                    });
            break;
    }
}
 
開發者ID:karlotoy,項目名稱:perfectTune,代碼行數:20,代碼來源:SignInActivity.java

示例4: handleSignInResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
/**
 * Handle google sign in result
 *
 * @param result the GoogleSignInResult result
 */
public void handleSignInResult(final GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        mGoogleApiClient.disconnect();
        verifySmartLockIsEnabled(new RxAccount(account));
    }
    else {
        // delete credential
        if(mCredential != null) {
            Auth.CredentialsApi.delete(mGoogleApiClient, mCredential).setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    mGoogleApiClient.disconnect();
                    mAccountSubject.onError(new Throwable(result.getStatus().toString()));
                }
            });
        }
        else {
            mGoogleApiClient.disconnect();
            mAccountSubject.onError(new Throwable(result.getStatus().toString()));
        }
    }
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:29,代碼來源:RxGoogleAuthFragment.java

示例5: onCreate

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);

    // Assign fields
    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);

    // Set click listeners
    mSignInButton.setOnClickListener(this);

    // Configure Google Sign In
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    // Initialize FirebaseAuth
}
 
開發者ID:firebase,項目名稱:friendlychat-android,代碼行數:24,代碼來源:SignInActivity.java

示例6: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed
            Log.e(TAG, "Google Sign In failed.");
        }
    }
}
 
開發者ID:firebase,項目名稱:friendlychat-android,代碼行數:18,代碼來源:SignInActivity.java

示例7: login

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
public void login(@NonNull SmartLoginConfig config) {
    GoogleApiClient apiClient = config.getGoogleApiClient();
    Activity activity = config.getActivity();

    if (apiClient == null) {
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestProfile()
                .build();

        apiClient = new GoogleApiClient.Builder(activity)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();
    }

    ProgressDialog progress = ProgressDialog.show(activity, "", activity.getString(R.string.logging_holder), true);
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(apiClient);
    activity.startActivityForResult(signInIntent, Constants.GOOGLE_LOGIN_REQUEST);
    progress.dismiss();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:GoogleLogin.java

示例8: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mCallbackManager.onActivityResult(requestCode, resultCode, data);
    twitter.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            checkconnection();
        }
    }
}
 
開發者ID:Shobhit-pandey,項目名稱:CollegeDoc,代碼行數:18,代碼來源:MainActivity.java

示例9: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGNIN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount account = result.getSignInAccount();
            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            auth.signInWithCredential(credential)
                    .addOnCompleteListener(this, this);
        } else
            onFailure(result.getStatus().toString());
    } else
        callbackManager.onActivityResult(requestCode, resultCode, data);
}
 
開發者ID:whirlwind-studios,項目名稱:School1-Android,代碼行數:17,代碼來源:SigninActivity.java

示例10: setUpGoogleAuth

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
private void setUpGoogleAuth() {
    // Configure sign-in to request the user's ID, email address, idToken and basic profile.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.client_id))
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(AppIndex.API).build();

    // Set GoogleApiClient into AppRunnest instance to be used in the rest of the application.
    ((AppRunnest) getApplication()).setApiClient(googleApiClient);
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:17,代碼來源:LoginActivity.java

示例11: pluginInitialize

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
protected void pluginInitialize() {
    Log.d(TAG, "Starting Firebase Authentication plugin");

    this.firebaseAuth = FirebaseAuth.getInstance();
    this.phoneAuthProvider = PhoneAuthProvider.getInstance();

    Context context = this.cordova.getActivity().getApplicationContext();
    String defaultClientId = getDefaultClientId(context);
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(defaultClientId)
            .requestEmail()
            .requestProfile()
            .build();

    googleApiClient = new GoogleApiClient.Builder(context)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    googleApiClient.connect();
    //firebaseAuth = FirebaseAuth.getInstance();
    //firebaseAuth.addAuthStateListener(this);
}
 
開發者ID:kanodeveloper,項目名稱:cordova-plugin-firebase-performance-ka,代碼行數:23,代碼來源:FirebaseAuthenticationPlugin.java

示例12: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
public void onActivityResult(int requestCode, int resultCode, Intent data) {
	// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);

	if (requestCode == Utils.FIREBASE_GOOGLE_SIGN_IN) {
		GoogleSignInResult result =
		Auth.GoogleSignInApi.getSignInResultFromIntent(data);

		isIntentInProgress = false;

		if (!mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); }

		if (result.isSuccess()) {
			// Google Sign In was successful, authenticate with Firebase

			GoogleSignInAccount account = result.getSignInAccount();
			firebaseAuthWithGoogle(account);
		} else {
			// Google Sign In failed, update UI appropriately
			// updateUI(null);
		}
	}
}
 
開發者ID:FrogSquare,項目名稱:GodotFireBase,代碼行數:23,代碼來源:GoogleSignIn.java

示例13: signOut

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
protected void signOut(GoogleApiClient googleApiClient){
    mAuth.signOut();

    Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull Status status) {
            Toast toast = Toast.makeText(AuthBaseActivity.this,
                    mResources.getString(R.string.sign_out_text),
                    Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 100);
            toast.show();

            Intent i = new Intent(AuthBaseActivity.this, SignInActivity.class);
            AuthBaseActivity.this.startActivity(i);
            AuthBaseActivity.this.finish();
        }
    });
}
 
開發者ID:AviralGarg1993,項目名稱:VR-One,代碼行數:19,代碼來源:AuthBaseActivity.java

示例14: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            setSessionManagement();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed, update UI appropriately
            // ...
        }
    }


}
 
開發者ID:yashovardhanagrawal,項目名稱:AddyHINT17,代碼行數:22,代碼來源:SignIn.java

示例15: onActivityResult

import com.google.android.gms.auth.api.Auth; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == CRDConstants.REQUEST_CODE_GOOGLE_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            logInToFirebaseWithGoogleSignIn(account);
        } else {
            Log.e(CRDAuthActivity.class.getName(), "onActivityResult().REQUEST_CODE_GOOGLE_SIGN_IN FAILED ! " + "getSignInResultFromIntent = [" + result.getStatus() + "]");
        }
    }
}
 
開發者ID:NinoDLC,項目名稱:CineReminDay,代碼行數:17,代碼來源:CRDAuthActivity.java


注:本文中的com.google.android.gms.auth.api.Auth類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。