菜鸟教程小白 发表于 2022-12-12 16:06:26

ios - 我的应用正在请求 “Have offline access” 的许可,为什么?


                                            <p><p>我的应用请求“离线访问”权限,为什么?这是最奇怪的事情。我做了一些搜索,并没有真正找到任何有效的方法。我已经尝试将这些用于范围:</p>

<pre><code>https://www.googleapis.com/auth/plus.profile.emails.read
https://www.googleapis.com/auth/plus.login
</code></pre>

<p>这似乎没有帮助。</p>

<p>以下是屏幕截图和我的一些代码,可帮助您了解发生了什么:</p>

<p> <a href="/image/nE5UR.png" rel="noreferrer noopener nofollow"><img src="/image/nE5UR.png" alt="enter image description here"/></a> </p>

<p>我的一些代码:</p>

<pre><code>    #import &#34;ViewController.h&#34;

NSString *callbakc =@&#34;http://localhost/&#34;;
NSString *client_id = @“CLIENT ID“;
NSString *scope = @&#34;https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.google.com/reader/api/0/subscription&#34;;
NSString *secret = @“SECRET”;
NSString *visibleactions = @&#34;http://schemas.google.com/AddActivity&#34;;

@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 {
;


NSString *url = ;

NSURLRequest *request = cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10];

;
}



#pragma mark - WebView Delegate

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {

;
if ([[ host] isEqualToString:@&#34;localhost&#34;]) {

    // Extract oauth_verifier from URL query
    NSString* verifier = nil;
    NSArray* urlParams = [[ query] componentsSeparatedByString:@&#34;&amp;&#34;];
    for (NSString* param in urlParams) {
      if (!) {
            NSArray* keyValue = ;
            NSString* key = ;
            if () {
                verifier = ;
//                  NSLog(@&#34;verifier %@&#34;,verifier);
                break;
            }
      }
      else {
            ;
      }
    }

    if (!verifier==0) {
      ;

      NSString *data = ;
      NSString *url = ;
      NSMutableURLRequest *request = [ initWithURL:];
      ;
      ];

      ;

      NSURLConnection *theConnection = [ initWithRequest:request delegate:self];
      NSLog(@&#34;Connection: %@&#34;, theConnection);

      self.receivedData = [ init];
    }
    else {
      // cancel button click
      NSLog(@&#34;not Verified!!&#34;);
    }

    return NO;
}
return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
// show progress
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

if (error.code==102) //Frame load interrupted
    return;

;
okAction:YES];
}

#pragma mark - NSURLConnection Delegate

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
;
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
okAction:YES];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

NSString *response = [ initWithData:self.receivedData encoding:NSUTF8StringEncoding];

NSData *data = ;
NSDictionary *tokenData = ;

if () {
    authAccessToken = ;
    ;
}
else {
    ;
    NSLog(@&#34;RESULT: %@&#34;, tokenData);
    message: okAction:YES];

    // Flush all cached data
    [ removeAllCachedResponses];
}

}

#pragma mark - Private Method Implementation

-(void)getUserInfo:(NSString *)token {
NSString *url = ;
NSMutableURLRequest *request = [ initWithURL:];
;
;

NSURLConnection *theConnection=[ initWithRequest:request delegate:self];
NSLog(@&#34;Connection: %@&#34;, theConnection);

self.receivedData = [ init];

}

-(void)progressDelay:(id)sender {
// Dismiss progress
}


@end
</code></pre>

<p>任何帮助将不胜感激! </p>

<p>谢谢</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这是来自 <a href="https://stackoverflow.com/questions/32210920/why-is-my-app-asking-for-permission-to-have-offline-access?answertab=oldest#tab-top" rel="noreferrer noopener nofollow">https://stackoverflow.com/questions/32210920/why-is-my-app-asking-for-permission-to-have-offline-access?answertab=oldest#tab-top</a> :</p>

<blockquote>
<p>This is normal behavior and occurs when the user has granted
permission already.</p>

<p>Basically, no need to worry about it unless you really don&#39;t want that
showing up, in that case, you need to un auth the users old token
before requesting a new one.</p>
</blockquote>

<p>我不确定如何操作,因为我以前没有这样做过,但是在您授权新 token 之前,您需要取消对旧 token 的授权。</p>

<p>您需要修改 <code>-(void)getUserInfo:(NSString *)token</code> 方法。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 我的应用正在请求“Have offline access” 的许可,为什么?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32195788/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32195788/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 我的应用正在请求 “Have offline access” 的许可,为什么?