Google Drive Api authentication in Android app -
i using google drive in android app application takes photos , uploads drive automatically, problem authentication asks choose google account first time when open app ,can programatically give credentials , make authentication done can avoid step of choosing , authentication ui.
you may refer link. can done oauth2 playground @ https://developers.google.com/oauthplayground.
steps:-
- create google account (eg. my.drive.app@gmail.com)
- use api console register mydriveapp (https://console.developers.google.com/apis/credentials/oauthclient?project=mydriveapp or https://console.developers.google.com/apis/)
- create new set of credentials (nb
oauth client id
notservice account key
, choose "web application" selection)- include https://developers.google.com/oauthplayground valid redirect uri
- note client id (web app) , client secret
- login my.drive.app@gmail.com
- go oauth2 playground
- in settings (gear icon), set * oauth flow: server * access type: offline * use own oauth credentials: tick * client id , client secret: step 5
- click step 1 , choose drive api https://www.googleapis.com/auth/drive (having said that, technique works of google apis listed)
- click authorize apis. prompted choose google account , confirm access
- click step 2 , "exchange authorization code tokens"
- copy returned refresh token , paste app, source code or in form of storage app can retrieve it.
you may use service account. however, create pseudo drive account app, rather allow app access regular drive account. check this.
Comments
Post a Comment