I was recently developing a simple Android application that would access Google Spreadsheets. To access the spreadsheet, the users would have to authorize the app to access their data. To get that authorization, I will have to use this command:
The problem was that, I was getting this error when getToken() executed:
After a bit of digging around, I realize that the reason for the error is the scope string. Here, I am using this:
oath2:https://spreadsheets.google.com/feeds https://docs.google.com/feeds
It should be this: https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/
That is, I don't have an option of choosing just a bunch of scopes. I will have to use all of the urls as scope.
Just FYI, I got the scope value for Google Spreadsheet from here
mToken = GoogleAuthUtil.geToken(MyActivity.this, accountName, "oauth2:https://spreadsheets.google.com/feeds https://docs.google.com/feeds");
Exception in getToken() - GoogleAuthException
com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at somepackage.LoginHomeActivity$2.doInBackground(LoginHomeActivity.java:80)
at somepackage.LoginHomeActivity$2.doInBackground(LoginHomeActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at somepackage.LoginHomeActivity$2.doInBackground(LoginHomeActivity.java:80)
at somepackage.LoginHomeActivity$2.doInBackground(LoginHomeActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
After a bit of digging around, I realize that the reason for the error is the scope string. Here, I am using this:
oath2:https://spreadsheets.google.com/feeds https://docs.google.com/feeds
It should be this: https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/
That is, I don't have an option of choosing just a bunch of scopes. I will have to use all of the urls as scope.
Just FYI, I got the scope value for Google Spreadsheet from here
No comments:
Post a Comment