Issue
I am using this library to do OAuth with Strava. It works fine till redirecting a user to the authentication page of Strava but the issue comes once the user approves the application. In error, it says that client_id is invalid but actually it isn't because 1) I double checked 2) If that's the case then it should give an error when opening authentication page but it didn't.
I don't know what is the best way to debug the error. I tried setting up debugger in Xcode but it didn't work as I was not getting a clear picture through debugging points.
I am pasting my code below:
App.js
import { authorize, refresh, revoke } from 'react-native-app-auth';
config = {
issuer: 'https://www.strava.com/oauth/mobile/authorize',
clientId: '***',
clientSecret: '*********',
redirectUrl: 'myapp://myapp.com/'
serviceConfiguration: {
authorizationEndpoint: 'https://www.strava.com/oauth/mobile/authorize',
tokenEndpoint: 'https://www.strava.com/oauth/token',
revocationEndpoint: 'https://www.strava.com/oauth/deauthorize'
},
additionalParameters: {
response_type: 'code',
approval_prompt: 'force',
grant_type: 'authorization_code'
},
scopes: ['activity:read']
};
try {
const authState = await authorize(this.config);
} catch (error) {
console.error(JSON.stringify(error));
}
Info.plist (iOS)
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp://myapp.com</string>
</array>
</dict>
AppDelegate.m
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"myapp"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
return [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url];
}
@end
I don't know what is the issue. Is it something related to code or Am I passing data wrong?
from Even if client id is correct its giving invalid client_id message in authorize callback
No comments:
Post a Comment