ios - My app is asking for permission to “Have offline access”, why? -


my app asking permission “have offline access”, why? it's weirdest thing. i've done bit of searching , haven't found that's worked. i've tried using these scopes:

https://www.googleapis.com/auth/plus.profile.emails.read  https://www.googleapis.com/auth/plus.login 

and didn't seem help.

below screenshot , of code see what's going on:

enter image description here

some of code:

    #import "viewcontroller.h"  nsstring *callbakc =  @"http://localhost/"; nsstring *client_id = @“client id“; nsstring *scope = @"https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.google.com/reader/api/0/subscription"; nsstring *secret = @“secret”; nsstring *visibleactions = @"http://schemas.google.com/addactivity";  @interface viewcontroller () { nsstring *authaccesstoken; uialertcontroller *alertcontroller; }  @property (strong, nonatomic) nsmutabledata *receiveddata; @property (weak, nonatomic) iboutlet uiwebview *webview;  @end  @implementation viewcontroller  #pragma mark - lifecycle  - (void)viewdidload { [super viewdidload];   nsstring *url = [nsstring stringwithformat:@"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=%@&redirect_uri=%@&scope=%@&data-requestvisibleactions=%@",client_id,callbakc,scope,visibleactions];  nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:url] cachepolicy:nsurlrequestreloadignoringlocalandremotecachedata timeoutinterval:10];  [_webview loadrequest:request]; }    #pragma mark - webview delegate  - (bool)webview:(uiwebview*)webview shouldstartloadwithrequest:(nsurlrequest*)request navigationtype:(uiwebviewnavigationtype)navigationtype {  [self performselector:@selector(progressdelay:) withobject:nil afterdelay:0.0]; if ([[[request url] host] isequaltostring:@"localhost"]) {      // extract oauth_verifier url query     nsstring* verifier = nil;     nsarray* urlparams = [[[request url] query] componentsseparatedbystring:@"&"];     (nsstring* param in urlparams) {         if (![param isequaltostring:@"error=access_denied"]) {             nsarray* keyvalue = [param componentsseparatedbystring:@"="];             nsstring* key = [keyvalue objectatindex:0];             if ([key isequaltostring:@"code"]) {                 verifier = [keyvalue objectatindex:1]; //                    nslog(@"verifier %@",verifier);                 break;             }         }         else {             [self.navigationcontroller popviewcontrolleranimated:no];         }     }      if (!verifier==0) {         [self showalertviewwithtitle:@"" message:@"please wait" okaction:no];          nsstring *data = [nsstring stringwithformat:@"code=%@&client_id=%@&client_secret=%@&redirect_uri=%@&grant_type=authorization_code", verifier,client_id,secret,callbakc];         nsstring *url = [nsstring stringwithformat:@"https://accounts.google.com/o/oauth2/token"];         nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:url]];         [request sethttpmethod:@"post"];         [request sethttpbody:[data datausingencoding:nsutf8stringencoding]];          [request sethttpshouldhandlecookies:no];          nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:request delegate:self];         nslog(@"connection: %@", theconnection);          self.receiveddata = [[nsmutabledata alloc] init];     }     else {         // cancel button click         nslog(@"not verified!!");     }      return no; } return yes; }  - (void)webviewdidstartload:(uiwebview *)webview { // show progress }  - (void)webviewdidfinishload:(uiwebview *)webview { [alertcontroller dismissviewcontrolleranimated:yes completion:nil]; }  - (void)webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error {  if (error.code==102) //frame load interrupted     return;  [alertcontroller dismissviewcontrolleranimated:yes completion:nil]; [self showalertviewwithtitle:@"error" message:[error localizeddescription] okaction:yes]; }  #pragma mark - nsurlconnection delegate  - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [self.receiveddata appenddata:data]; }  - (void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error{ [self showalertviewwithtitle:@"error" message:[nsstring stringwithformat:@"%@", error] okaction:yes]; }  - (void)connectiondidfinishloading:(nsurlconnection *)connection {  nsstring *response = [[nsstring alloc] initwithdata:self.receiveddata encoding:nsutf8stringencoding];  nsdata *data = [response datausingencoding:nsutf8stringencoding]; nsdictionary *tokendata = [nsjsonserialization jsonobjectwithdata:data options:0 error:nil];  if ([tokendata objectforkey:@"access_token"]) {     authaccesstoken = [tokendata objectforkey:@"access_token"];     [self getuserinfo:authaccesstoken]; } else {     [alertcontroller dismissviewcontrolleranimated:yes completion:nil];     nslog(@"result: %@", tokendata);     [self showalertviewwithtitle:[tokendata objectforkey:@"name"] message:[nsstring stringwithformat:@"%@", tokendata] okaction:yes];      // flush cached data     [[nsurlcache sharedurlcache] removeallcachedresponses]; }  }  #pragma mark - private method implementation  -(void)getuserinfo:(nsstring *)token { nsstring *url = [nsstring stringwithformat:@"https://www.googleapis.com/oauth2/v1/userinfo?access_token=%@",token]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:url]]; [request sethttpmethod:@"get"]; [request sethttpshouldhandlecookies:no];  nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:request delegate:self]; nslog(@"connection: %@", theconnection);  self.receiveddata = [[nsmutabledata alloc] init];  }  -(void)progressdelay:(id)sender { // dismiss progress }   @end 

any appreciated!

thank you

this https://stackoverflow.com/questions/32210920/why-is-my-app-asking-for-permission-to-have-offline-access?answertab=oldest#tab-top:

this normal behavior , occurs when user has granted permission already.

basically, no need worry unless don't want showing up, in case, need un auth users old token before requesting new one.

i'm not sure how because haven't done before, before authorize new token need un-authorize old one.

you'll need modify -(void)getuserinfo:(nsstring *)token method.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -