O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Smart Lock for Password @ Game DevFest Bangkok 2015

1.474 visualizações

Publicada em

สไลด์ประกอบบรรยายหัวข้อ Smart Lock for Password เป็น API ตัวใหม่ของของ Google สำหรับ Android และ Chrome

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Smart Lock for Password @ Game DevFest Bangkok 2015

  1. 1. Smart Lock for Passwords Somkiat Khitwongwattana Android Developer@Nextzy & Android GDE & Contributor@Droidsans
  2. 2. Smart Lock for Passwords Smart Lock • Signed-in across devices • For Android and Chrome • Reduce the risk of forgotten
  3. 3. Smart Lock for Passwords Credentials API • Retrieve and save app login credentials • Auth.CREDENTIALS_API • Multiple user credentials supported
  4. 4. Smart Lock for Passwords Credential Management Capability • Username • Name • Password • Profile Picture URL • Account Type
  5. 5. Smart Lock for Passwords Smart Lock Flow • Auto sign-in • Multiple credentials • No credentials / Signed out • App start • Signed in
  6. 6. Smart Lock for Passwords Smart Lock Flow
  7. 7. Smart Lock for Passwords No credentials / Signed out
  8. 8. Smart Lock for Passwords Auto sign-in
  9. 9. Smart Lock for Passwords Multiple credentials
  10. 10. Smart Lock for Passwords Get Started • Add Google Play Services dependency compile  'com.google.android.gms:play-­‐services:7.8.0' • Declare the version of Google Play services <application>     ...     <meta-­‐data  android:name="com.google.android.gms.version"                          android:value="@integer/google_play_services_version"  />     ...   </application>
  11. 11. Smart Lock for Passwords Get Started • Create an OAuth 2.0 client ID • Open Google Developer Console • Create project
  12. 12. Smart Lock for Passwords Get Started • Setup OAuth consent screen
  13. 13. Smart Lock for Passwords Get Started • Create client ID
  14. 14. Smart Lock for Passwords Get Started• Setup client ID
  15. 15. Smart Lock for Passwords Get Started • Example client ID 478989446966-gdahdsjn77selo6f1rnab6e2pd1nq4f3.apps.googleusercontent.com
  16. 16. Smart Lock for Passwords Let's Get Coding GoogleApiClient  mCredentialsApiClient;   ...   mCredentialsApiClient  =  new  GoogleApiClient.Builder(this)       .addConnectionCallbacks(this)       .enableAutoManage(this,  0,  this)       .addApi(Auth.CREDENTIALS_API)       .build();
  17. 17. Smart Lock for Passwords Store Credentials Credential  credential  =  new  Credential.Builder(username)       .setPassword(password)       .setAccountType(accountType)       .setName(name)       .setProfilePictureUri(url)       .build();
  18. 18. Smart Lock for Passwords Store Credentials Auth.CredentialsApi.save(mCredentialsApiClient,  credential)
                .setResultCallback(new  ResultCallback<Status>()  {          @Override          public  void  onResult(Status  status)  {                  ...          }   });
  19. 19. Smart Lock for Passwords Store Credentials int  REQUEST_CODE_SAVE  =  123;   Status  status  =  result.getStatus();   if(status.isSuccess())  {          ...   }  else  {          if(status.hasResolution())  {                  status.startResolutionForResult(this,  REQUEST_CODE_SAVE);          }  else  {                  ...          }   }
  20. 20. Smart Lock for Passwords Store Credentials
  21. 21. Smart Lock for Passwords Store Credentials @Override   public  void  onActivityResult(int  requestCode,  int  resultCode,  Intent  data)  {          ...          if  (requestCode  ==  REQUEST_CODE_SAVE)  {                  if  (resultCode  ==  RESULT_OK)  {                          ...                  }  else  {                          ...                  }          }          ...   }
  22. 22. Smart Lock for Passwords Request Credentials CredentialRequest  request  =  new  CredentialRequest.Builder()                  .setSupportsPasswordLogin(true)                  .build();
  23. 23. Smart Lock for Passwords Request Credentials Auth.CredentialsApi.request(mCredentialsApiClient,  request)                  .setResultCallback(new  ResultCallback<CredentialRequestResult>()  {          @Override          public  void  onResult(CredentialRequestResult  credentialRequestResult)  {                  ...          }   });
  24. 24. Smart Lock for Passwords Share Credentials with Apps and Sites • Verify website's sign-in domain by using the Google Search Console • Make an association to Play Developer Console • Must be available through HTTPS
  25. 25. Smart Lock for Passwords Share Credentials with Apps and Sites
  26. 26. Smart Lock for Passwords Share Credentials with Apps and Sites
  27. 27. Smart Lock for Passwords Reference https://developers.google.com/identity/smartlock-passwords https://www.youtube.com/watch?v=M3Udfu6qidk Smart Lock for Passwords Documentation Google Play Services 7.5 (100 Days of Google Dev)

×