I know it seems to be a silly question and URL parsing is easy to search, but I am really facing hard time to get the access token from the given URL below.
My code
NSString* u = [[[[frame dataSource]request]URL]absoluteString];
NSString* output = nil;
if([u hasPrefix:@"https://login.live.com/oauth20_desktop.srf"])
{
NSMutableDictionary *queryStringDictionary = [[NSMutableDictionary alloc] init];
NSArray *urlComponents = [u componentsSeparatedByString:@"&"];
for (NSString *keyValuePair in urlComponents)
{
NSArray *pairComponents = [keyValuePair componentsSeparatedByString:@"="];
NSString *key = [[pairComponents firstObject] stringByRemovingPercentEncoding];
NSString *value = [[pairComponents lastObject] stringByRemovingPercentEncoding];
[queryStringDictionary setObject:value forKey:key];
}
}
Result
{
"expires_in" = 3600;
"https://login.live.com/oauth20_desktop.srf?lc" = "EwCIAq1DBAAUGCCXc8wU/zFu9QnLdZXy+YnElFkAAYQSbBaTYP1E4GlmB6vPpa9noNLSSg+FzA88BgdO2lFbr3EzR9POPhf417OAqXB7dlhZ7q/3AEhxthlBwFb3IebkElbeKUZll0QeIf7HniteFGJA0nD81xv01CHwjnJ0g/eIuh2GH8kE8/dL9seRMN4ngayEpV4Kp5/k3o1z9nDhtmn9/pZfspIlXo75Km9n2hqPAGt+7przBmYZZZGgLiQitQDCQEBidgKDfLjBmO5ZjbYFGuwCJz1Hmlsbs+e45MuF+VF4uk7ocAu8CQnFrYdVusPPS04QR2EzUkGt3uEBM7jmqnjZfM+EJ78kggmuPXuxkMarNsGiMYdzigNxIHEDZgAACE0dTsiQuAaFWAFL7tvmsSOprKe2jx4FrRgZhWn5F9vQTKw9thK63urFSY79m/CbLqQSlEMKLi4mRptJa+tXKFpg9anxHMyfvMSDQ5ryWK291qJX5W5Yv5syxSm3u6PEo8KM9WmeAdCW/trJzrCIVPrSdshzvI2N5Iu+SP9igWGDoWdE6uoH7G0ZA8gPn2v3NagzVNKUyIKuceiT3fI20nBCYx/6+N5Z/WWKmmkyuuAqo3kH5+FrGz2lz4F5tP0UOdYjY6q73RqUQMLwdJ2/3UNb3BcE/98nGbOgKMtCPPCx0GaPBwOPlVkvxqMa6oeNaHmArZNsyhwuvJEfWEbB+HLXtE5gYG5PziybUDeLa+uIJda9z0Tb9HRyMb+I2nA7+SMkhgITyo2OplaTMRVrKAGHViEDVSBMbspkbG6tV/nk/7SC3/cICXGPFX9u29sEcGe6l0onMQougQvhuXs90CFVNkVG8B";
scope = "wl.signin wl.offline_access onedrive.readwrite wl.basic";
"token_type" = bearer;
"user_id" = 6c0a5d79b74cefa0c6d9d5f302a14876;
}
Problem
As you can see in the above result, there is a key https://login.live.com/oauth20_desktop.srf?lc I think it should be Access_Token
Any suggestions are appreciated. Thank you so much.