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 "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 {
;
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:@"localhost"]) {
// Extract oauth_verifier from URL query
NSString* verifier = nil;
NSArray* urlParams = [[ query] componentsSeparatedByString:@"&"];
for (NSString* param in urlParams) {
if (!) {
NSArray* keyValue = ;
NSString* key = ;
if () {
verifier = ;
// NSLog(@"verifier %@",verifier);
break;
}
}
else {
;
}
}
if (!verifier==0) {
;
NSString *data = ;
NSString *url = ;
NSMutableURLRequest *request = [ initWithURL:];
;
];
;
NSURLConnection *theConnection = [ initWithRequest:request delegate:self];
NSLog(@"Connection: %@", theConnection);
self.receivedData = [ init];
}
else {
// cancel button click
NSLog(@"not Verified!!");
}
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(@"RESULT: %@", 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(@"Connection: %@", 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'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]