优步 iOS SDK - 401 错误
UBER iOS SDK - 401 error
我正在按照 UBER iOS SDK 文档将优步集成到我的应用程序中。
https://github.com/uber/rides-ios-sdk
我正在尝试将 "Ride Request Button" 集成到我的应用程序中,我从文档中复制并粘贴了示例代码
UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
[self view] addSubview:button];
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude: 37.787654 longitude: -122.402760];
CLLocation *dropoffLocation = [[CLLocation alloc] initWithLatitude: 37.775200 longitude: -122.417587];
__block UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
builder = [builder setPickupLocation: pickupLocation];
builder = [builder setDropoffLocation: dropoffLocation];
[ridesClient fetchCheapestProductWithPickupLocation: pickupLocation completion:^(UBSDKUberProduct* _Nullable product, UBSDKResponse* _Nullable response) {
if (product) {
builder = [builder setProductID: product.productID];
button.rideParameters = [builder build];
[button loadRideInformation];
}
}];
块 UBSDKResponse (response.response) 如下所示
<NSHTTPURLResponse: 0x15c6c1eb0> { URL: https://sandbox-api.uber.com/v1/products?latitude=37.787654&longitude=-122.40276 } { status code: 401, headers {
Connection = "keep-alive";
"Content-Length" = 63;
"Content-Type" = "application/json";
Date = "Thu, 01 Sep 2016 21:39:12 GMT";
Server = nginx;
"Strict-Transport-Security" = "max-age=0";
"X-Content-Type-Options" = nosniff;
"X-Uber-App" = "uberex-sandbox, migrator-uberex-sandbox-optimus";
"X-XSS-Protection" = "1; mode=block";
} }
我在 info.plist 文件中的应用程序中配置了 UberClient ID。不确定我缺少什么才能获得 401 响应。
谢谢
您只需将服务器令牌添加到您的 Info.plist。
将此代码段复制到您的 Info.plist
(右键单击并 select 打开方式 > 源代码)并将 [Your Server Token]
替换为服务器来自您的 dashboard 的令牌(确保您使用与您的客户端 ID 对应的服务器令牌)。
<key>UberServerToken</key>
<string>[Your Server Token]</string>
希望对您有所帮助!
我正在按照 UBER iOS SDK 文档将优步集成到我的应用程序中。
https://github.com/uber/rides-ios-sdk
我正在尝试将 "Ride Request Button" 集成到我的应用程序中,我从文档中复制并粘贴了示例代码
UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
[self view] addSubview:button];
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude: 37.787654 longitude: -122.402760];
CLLocation *dropoffLocation = [[CLLocation alloc] initWithLatitude: 37.775200 longitude: -122.417587];
__block UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
builder = [builder setPickupLocation: pickupLocation];
builder = [builder setDropoffLocation: dropoffLocation];
[ridesClient fetchCheapestProductWithPickupLocation: pickupLocation completion:^(UBSDKUberProduct* _Nullable product, UBSDKResponse* _Nullable response) {
if (product) {
builder = [builder setProductID: product.productID];
button.rideParameters = [builder build];
[button loadRideInformation];
}
}];
块 UBSDKResponse (response.response) 如下所示
<NSHTTPURLResponse: 0x15c6c1eb0> { URL: https://sandbox-api.uber.com/v1/products?latitude=37.787654&longitude=-122.40276 } { status code: 401, headers {
Connection = "keep-alive";
"Content-Length" = 63;
"Content-Type" = "application/json";
Date = "Thu, 01 Sep 2016 21:39:12 GMT";
Server = nginx;
"Strict-Transport-Security" = "max-age=0";
"X-Content-Type-Options" = nosniff;
"X-Uber-App" = "uberex-sandbox, migrator-uberex-sandbox-optimus";
"X-XSS-Protection" = "1; mode=block";
} }
我在 info.plist 文件中的应用程序中配置了 UberClient ID。不确定我缺少什么才能获得 401 响应。
谢谢
您只需将服务器令牌添加到您的 Info.plist。
将此代码段复制到您的 Info.plist
(右键单击并 select 打开方式 > 源代码)并将 [Your Server Token]
替换为服务器来自您的 dashboard 的令牌(确保您使用与您的客户端 ID 对应的服务器令牌)。
<key>UberServerToken</key>
<string>[Your Server Token]</string>
希望对您有所帮助!