1.1/users/show.json Could not authenticate you error 32. How to solve it?


#1

Hello!

I move application to new API 1.1 and get error 32

Here is a request
Request

curl -X GET -H “Authorization: OAuth oauth_nonce=“5D4C9396-6B2A-47EA-815B-873CADE2B523”, oauth_timestamp=“1355400810”, oauth_version=“1.0”, oauth_consumer_key=”${CONSUMER_KEY}", oauth_token="${OAUTH_TOKEN}", oauth_signature=“ZnH4Kc8A28qd3G5TDtxNhGW68r8%3D”, oauth_signature_method=“HMAC-SHA1"” -H “Accept-Language: en, fr, de, ja, nl, it, es, pt, pt-PT, da, fi, nb, sv, ko, zh-Hans, zh-Hant, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us” “https://api.twitter.com/1.1/users/show.json?include_entities=true&screen_name=${MY_NAME}

what’s wrong?


#2

this method i use for oauth_signature
// RSOAuthEngine <- library, that i use

  • (NSString *)signatureBaseStringForRequest:(MKNetworkOperation *)request
    {
    NSMutableArray *parameters = [NSMutableArray array];
    NSURL *url = [NSURL URLWithString:request.url];

    // Get the base URL String (with no parameters)
    NSArray *urlParts = [request.url componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"?#"]];
    NSString *baseURL = [urlParts objectAtIndex:0];

    // Add parameters from the query string
    NSArray *pairs = [url.query componentsSeparatedByString:@"&"];
    [pairs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    NSArray *elements = [obj componentsSeparatedByString:@"="];
    NSString *key = [[elements objectAtIndex:0] urlEncodedString];
    NSString *value = (elements.count > 1) ? [[elements objectAtIndex:1] urlEncodedString] : @"";

      [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:key, @"key", value, @"value", nil]];
    

    }];

    // Add parameters from the request body
    [request.readonlyPostDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
    [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:[key urlEncodedString], @“key”, [obj urlEncodedString], @“value”, nil]];
    }];

    // Add parameters from the OAuth header
    [oAuthValues enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
    if ([key hasPrefix:@"oauth
    "] && ![key isEqualToString:@“oauth_signature”] && obj && ![obj isEqualToString:@""]) {
    [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:[key urlEncodedString], @“key”, [obj urlEncodedString], @“value”, nil]];
    }
    }];

    // Sort by name and value
    [parameters sortUsingComparator:^(id obj1, id obj2) {
    NSDictionary *val1 = obj1, *val2 = obj2;
    NSComparisonResult result = [[val1 objectForKey:@“key”] compare:[val2 objectForKey:@“key”] options:NSLiteralSearch];
    if (result != NSOrderedSame) return result;
    return [[val1 objectForKey:@“value”] compare:[val2 objectForKey:@“value”] options:NSLiteralSearch];
    }];

    // Join sorted components
    NSMutableArray *normalizedParameters = [NSMutableArray array];
    [parameters enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    [normalizedParameters addObject:[NSString stringWithFormat:@"%@=%@", [obj objectForKey:@“key”], [obj objectForKey:@“value”]]];
    }];

    // Create the signature base string
    NSString *signatureBaseString = [NSString stringWithFormat:@"%@&%@&%@",
    [[request HTTPMethod] uppercaseString],
    [baseURL urlEncodedString],
    [[normalizedParameters componentsJoinedByString:@"&"] urlEncodedString]];

    return signatureBaseString;
    }


#3

task closed, because this method not valid for signature. it duplicate parameters of query


#4

I’m having this exact issue. Can you better describe how you managed to get it working?